Antaris / RazorEngine

Open source templating engine based on Microsoft's Razor parsing engine
http://antaris.github.io/RazorEngine
Other
2.14k stars 577 forks source link

Support for hooking into the parser process? #384

Closed fatso83 closed 8 years ago

fatso83 commented 8 years ago

As an alternative to stubbing out required functionality used in the templates (like Html.Raw and friends) I was thinking that an easier way out is to support replacements for various code calls.

For instance, if coming across Url.Route(foo, bar, { foo : bar }) it could be substituted with the static string "/foo/bar" before trying to execute the compiled template later on.

Instead of writing my own (bad) Razor parser from scratch, I was thinking that it might be possible to hook into the Razor parser directly, somehow, to do such things. Is this in any way supported by the current RazorEngine code?

matthid commented 8 years ago

RazorEngine doesn't actually contain any parser code at all, we just use the Razor engine (the MVC engine actually sits on top, exactly like we do). So basically the answer is no you can't (at least from our perspective).

On the other side the raw Razor Api gives you a lot of extension points and is now open source since version 4: https://github.com/aspnet/Razor (MVC is here https://github.com/aspnet/Mvc by the way)

Since this is all new it might be possible to use the real MVC classes now as they should be pretty self contained because of moving to corefx and stuff.

fatso83 commented 8 years ago

Ok, thanks. Looking into it.