kirbysayshi / vash

Vash, the 60 billion double-dollar template-maker. Razor syntax, for JavaScript templates
Other
524 stars 60 forks source link

Support for multiple @{name} helpers #97

Open ETNOL opened 8 years ago

ETNOL commented 8 years ago

I'm trying to use vash to render cshtml files. I'm having decent luck after extending the helpers as needed but I'm stuck on rendering the @helper () { } methods in my razor files.

Is there a not-so-painful way to create another @{namespace} like @html that acts as like razor's @helper?

I know this isn't vash's intended use but, since I'm pretty close to pulling it off, I figured I'd ask if this was possible.

kirbysayshi commented 8 years ago

It's currently not possible to have multiple internal namespaces for a template, since that is defined all the way from the config, through the compiler, and even in the runtime / linker. But you could hack this with some sort of globals, I suppose. But that sounds pretty hacky.

You might be better off preprocessing your cshtml files with a regex that replaces the @helper keyword with an assignment to a global namespace?