9

I wonder if there is any way to extend razor view engine capabilities to handle some custom text/tag and parse/proceed before render. Assume that I use some special tag which is ${} as below:

<span>${some word}</span>

Then, I want to parse the view before render and replace 'some world' with localized value. Ofcourse this can be done by other ways, but i wonder if there is any way to get this work.

6
  • 1
    For localized values, you should really use a resource file. For your question in hand though, check out this blog post on different methods of templating etc with Razor: blogs.msdn.com/b/marcinon/archive/2010/12/08/… Jan 16, 2013 at 14:30
  • 1
    There's also functions in Razor too blogs.msdn.com/b/timlee/archive/2010/07/30/… Jan 16, 2013 at 14:33
  • I know about the ways. But I really wonder if there is any way to handle rendering, parsing view text and put some values on view, then realse for rendering. Jan 16, 2013 at 14:36
  • Typically though, that wouldn't be done as part of "rendering", that's something you want from a template/function. Jan 16, 2013 at 14:38
  • @Halil Ibrahim +1 for the question. That's for really devoted developers (what's your twitter?). he he And also why don't you mark the answer as actually an answer to the question. For me, that's exactly what's needed (especially, with the link to Nancy).
    – Agat
    Nov 13, 2013 at 18:07

1 Answer 1

5

You can extend the razor view engine by inhereting from RazorViewEngine class, you can find an example of how to do that here

Also, check out Nancy.Viewengines.Razor which is a view engine built on top of Razor view engine, and has it's own syntax parser

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.