Extending Razor View Engine to Handle Rendering
Asked Answered
C

1

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.

Catacomb answered 16/1, 2013 at 14:27 Comment(6)
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/…Corrigendum
There's also functions in Razor too blogs.msdn.com/b/timlee/archive/2010/07/30/…Corrigendum
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.Catacomb
Typically though, that wouldn't be done as part of "rendering", that's something you want from a template/function.Corrigendum
@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).Lysimachus
@Lysimachus I missed to mark the answer, that's an old question. Thanks for reminding :)Catacomb
G
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

Georas answered 16/1, 2013 at 16:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.