Probably would need to be in <spark> config or ISparkSettings for the
settings to be available before the parse occurs. Which is a shame - I
really like how putting <use namespace> and <use assembly> in
_global.spark reduces dependency on web.config.
Don't other things like partials and macros also affect the
portability? If I have <rounded>stuff</rounded> that won't work
without _rounded.spark.
I agree config is suboptimal, and it does head down a configuration
over convention path, but who can say what helpers are most useful.
That's why ${expr} and <%=expr%>, #stmt and <%stmt%>, are both
supported - it's not that there's anything right or wrong about the
alternatives and supporting both doesn't negatively impact either one.
I'd lean more towards making it configurable than adding universal
meaning to a number of different syntax.
On the other hand it would be pretty easy to turn your spark files
into a mass of unreadable shortcuts. Okay - how about moving away from
the idea of using punctuation, and instead use small expansion marks
that start with $...
<expansions>
<add mark="$" expansion="{0}"/>
<add mark="$$" expansion="H({0})"/>
<add mark="$H" expansion="H({0})"/>
<add mark="$A" expansion="Html.AttributeEncode({0})"/>
<add mark="$L" expansion="Html.ActionLink({0})"/>
</expansions>
${Html.TextBox("blah")}
<span title="$A{product.About}">$H{product.Name}</span>
$L{"Go back", "index", "home"}
To encourage portability and convention you could provide a small set
of compatible defaults for monorail and
asp.net mvc, like the ones
above. Configuration only needed to extend or modify defaults, if you
never use them they won't affect anything, and still reads like ${}
visually and hopefully more intuitive than punctuation.
(Not trying to pitch the idea of course, just talking it through.)
I wonder if you would apply the same idea to <%= %>?
<add mark="%=" expansion="{0}"/>
<add mark="%H" expansion="Html.Encode({0})"/>
<add mark="%L" expansion="Html.ActionLink({0})"/>
<add mark="%Link" expansion="Html.ActionLink({0})"/>
<%H product.Name%>
<%L "Go Back", "Index", "Home" %>
<%Link "Go Back", "Index", "Home" %>
On Dec 17, 1:05 pm, "Chad Lee" <
chadl...@gmail.com> wrote:
> I agree with Kevin that making something like that configurable would hurt
> the portability of the code. Not to mention the difficulty in having to
> figure out the different syntax that someone is using when moving to a new
> code base.
>
> Granted, it probably won't be a problem 90% of the time given that most
> people won't change the defaults, but given that, why even make it an
> option?
>
> Again, I think it is too much risk for not much value. I'm fine with
> ${H()}.
>