I've been using the Bindings feature with the spark view engine to replace quite a few of my Html helper method calls.
One problem I have is that I want to define a css class to pass in to the anonymous dictionary parameter of the helper methods, which I would normally do like this:
${Html.EditorFor(x=>x.Username, new{@class = "css-class"})}
Replacing this with a spark Binding looks like this:
Binding:
<element name="Editor">Html.EditorFor(x => x.@For, new {"@*"}) </element>
View Element:
<Editor For="Password" class="css-class" />
I get an error "A namespace cannot directly contain members such as fields or method" which is valid because it is resolving to
Output.Write(Html.EditorFor(x => x.Password, new {class="big"}) );
The issue is obviously that I need to use @class instead of class.
However, I can't specify @class in the html attribute like this
<Editor For="Password" @class="css-class" />
Because spark ignores it.
I also can't specify it like this:
<element name="Editor">Html.EditorFor(x => x.@For, new {@"@*"}) </element>
Because then every html attribute that gets passed through will be prefixed with the @ symbol.
So my question is, how can I pass the class
HTML attribute through to the spark binding when using it to initialize a dictionary parameter so that it doesn't throw a compiler error?