Feature Request: Razor syntax for creating functions

Topics: MVC
Jan 26, 2011 at 6:52 PM

Okay, so we have Visual Functions and XSLT functions and C# that we can use to insert content into our pages. With the release of Razor, why not add a option to create Razor templates that can be rendered by passing some predefined model into it. There have been alot buzzing going on with the release of Razor and how its not tied into MVC or Web, meaning you can host the Razor engine your self.





I see that Marcus has been playing around with Razor a bit, but it has all been in the context of MVC applications. Following the original philosophy of C1, we should be able to use Razor whether we like MVC or not.

Jan 26, 2011 at 7:43 PM

Okay, so by using just the C# functions feature of C1 i was able to create a generic C# function that takes a cshtml-filename and some data as argument, and return the rendered text. I imagine that the only special thing we need here is a Razor engine host and a editor with Razor syntax highlighting inside C1.

Jan 26, 2011 at 9:09 PM

Sweet indeed! Do you have any take on how parameters could get into the mix? Have a base class like MVC Razor does? We should have parameter support - C1 Function parameters rock!

Something like this.GetParameter<T>( param name ) for the strongly typed lovers and this.Parameter.SomeParamName for the dynamic freaks ;-)

I you dive deep into this IFunctionProvider is the interface to implement :-)


Jan 26, 2011 at 10:52 PM

About parameters - we can do the same way as we agreed for aspx-controls at the last ASP.NET workshop

Feb 27, 2011 at 1:36 PM

Created a issue item here http://compositec1.codeplex.com/workitem/588