views:

154

answers:

3

Razor view engine looks promising, so I thought it would be good to contribute with ideas and compile a wish-list of Razor features while the development is just in preview stage.

What are the features you miss today in Spark, Webforms, or early Razor release and would like to be implemented in Razor?

UPD: Why close this question??? What's wrong with creating a feedback loop to Razor developers using this media?

+4  A: 

I would like to have a directive to switch off line breaks in HTML output.

@linebreaks off
<span>the three spans</span>
<span>will be rendered</span>
<span>all in one line</span>
@linebreaks on

The above should produce

<span>the three spans</span><span>will be rendered</span><span>all in one line</span>
Andy
Is there a particular reason you want a directive or would a global or per-page setting work just as well?
anurse
I want a directive: so that I can preserve the layout in most of the places, however being able to switch off line breaks to render sensitive elements, such as a horisontal list of links, where a line-break in HTML inserts one extra uncontrolled space between the neighbouring elements. BTW a directive may also have a per-page effect, if applied early in the code.
Andy
Or, best would be to expose properties within the View class through which the developer could control the rendering at run-time, directly from the Razor code: switching off/on line breaks or switching off/on the leading spaces in HTML output. Thereby we elimiate the need for an extra directive and achieve flexibility of control.
Andy
+1  A: 

Need to change source code extensions, to make sure it's not "cshtml" and "vbhtml", but something shorter, like "cz" and "vz".

Andy
Care to elaborate on why you prefer a shorter extension? (Btw, I _am_ a developer on the ASP.NET team)
marcind
@marcind: usability: the shorter the names, the more open files will fit on the editor bar. Developers want to quickly find the right name, so stripping the extension name to the bare "cz" or "vz" will also help eliminate some visual noise and will allow to focus on the essentials.
Andy
+2  A: 

I want to still be able to specify content type in some sort of directive.

Not we can do this in asp.net mvc:

<%@ Page ... ContentType="application/rss+xml" %>

I'm using this for RSS.

denis_n
Isn't that suppose to be in the controller?
Manticore
It depends. I like to generate rss in view and to set content type decoratively (opposite to doing everything in controller's action). After all rss is just xml, like html.
denis_n
You can access the `HttpResponseBase` object from a Razor view and set the ContentType on it. However, I would agree with Manticore in that you should probably do this in the controller.
marcind
Setting content type from Razor is a bad idea. But setting content type in a declarative (I misspelled this word in my previous answer) way is something different. Anyway, I would like this to be implemented.
denis_n
@denis_n why do you say that the declarative way is fine while setting it 'from Razor is a bad idea'? They would end up being the same exact thing in Razor (i.e. whatever @contentType 'text/html' directive would be translated by the parser into a call that would invoke some method or set some property on the page)
marcind
I would like it to be done by framework, not by hand.@ContentType is better than setting content type through HttpResponseBase object. It requires less code. And less is more :)
denis_n
I agree that less is more, which is why I would think we should avoid introducing _more_ syntax for a very minimal benefit.
anurse
Maybe you are right. Maybe we should check the extension: *.rss.rz and provide the correct content type.
denis_n