I saw a comment the other day on a post about asp.net mvc. The post was old enough that additional comments were no longer being accepted, but I thought the points raised were worth a response.
Today we see there are many view engines. What is the implication of that? They offer a lot of convenience, but you can’t step through them with the debugger. Are they even compiled? It could be that under load you will find that the view engine spends a lot of time interpreting the ’smart’ notation they came up with.
Talking of view engines, this is some spark I saw the other day, I’ll let the code speak for itself:
<test if="expression">
...
<else/>
...
</test>
And the answer is… Heck yeah it’s compiled! You can view the generated source at any time and you can absolutely step through it with a debugger. Lucky.
Read the rest of this entry »
Tagged geek, internet, programming, spark. Posted in spark
A few more tricks added to Spark language. There was a question about how you would have an attribute that is present or not based on a condition. Say you have a bool isFooChecked variable and you want to do the following:
<input type="checkbox"
name="foo"
${isFooChecked ? 'checked=""' : ''}></input>
That doesn’t work of course… Spark elements are parsed by the xml spec. Plus this type of thing really messes with typical xml editors like Visual Studio, so keeping roughly xml spec compatible is one of the goals.
After mucking around with a few different ways you could express a conditional attribute, while trying to keep the attribute valid, one of them really stood out. Since there’s already a ${expr} syntax to output text, adding a ?{expr} to control the output seemed like an intuitive approach.
So the above example becomes:
<input type="checkbox"
name="foo"
checked="?{isFooChecked}"></input>
Read the rest of this entry »
Tagged geek, internet, programming, spark. Posted in spark
There are a number of requests queued up in Spark that deal with the same general realm of precompilation… I think the first was from Chadly who was asking about compiling everything up-front, and as he mentions it’s exactly the type of thing that opens the door to building all of your views into a deployable assembly.
The next was from ilog2000 who mentioned that Spark can’t function in a partially trusted (shared) environment. It’s a restriction the framework is imposing on class libraries that attempt to generate, compile, and load assemblies. Reasonably enough precaution I suppose.
So that’s the most recent thing that’s being implemented. The castle version was a bit more complex - because there are the layout and area attributes to watch out for (not to mention view components) - but a new release should come together in a few days.
But it is convenient. In fact just earlier today when I added a “compile all views” unit test to the current project I’m on at the office it showed one place where a status/info page was out of date (it wouldn’t compile because the layout had changed) and another place where a handful of obsolete view files were sitting around on disk for no reason. Plus from this point resharper and the continuous-integration will be able to point out any place someone has broken a view.
I suppose at that point you could also unit test the actual view classes themselves - instantate, hand them view data, and render - although I’m not sure if there’s a lot of value in doing that.
Tagged development, geek, internet, programming, spark. Posted in internet, opensource, spark
End of the third day at Gen Con and everyone’s having a great time. Just got back from watching a few more films. Brenda and her niece Zhenn, who she brought along for shopping and sightseeing, are suprised how much they’re enjoying the convention. She was expecting to spend one day at the place, but has ended up coming down at least part of the time each day. Our other travelling companions, Brenda’s cousin Abe and his friend Tony, are still in the middle of a Magic tournament which will probably last until five in the morning. They’ve decided to spend the night at the convention center - should be quite an experience.
This evening was a dance at the Union Station Grand Ballroom where people are invited to wear costumes, which B was interested in of course. She and Zhenn spent Friday shopping around and piecing together outfits which they wore to the convention today and had some time with professional fantasy makeup person.
So all day today they’ve had people with cameras asking to take their pictures, and asking them to pose with the other convention goers in costume. Which has been the highlight of their trip so far - they love the attention.
Alex is really enjoying the trip also. He’s picked up a number of boxes of World of Warcraft booster packs, which we’ve been playing, and we spent over three hours today building gigantic weapons. I’ve got a large Buster-style sword and Alex has a war hammer larger than he is. So we’ve also had our share of pictures taken as we wandered the halls and booths.
Sunday’s the last day and after the doors close we’re going to be going to the Indianapolis fair. Drive home Monday and after a few days of sleep everything should be back to normal. :)
Tagged family, gencon, vacation. Posted in family
This post is about a request for a feature from Torkel Ödegaard the other week.
Would it be possible to send the inner text to a partial?
For example lets say we have a partial named _text.spark
<text key="my_text_key">
some inner text to send to the partial view,
in this case the default text for this text key.
</text>
If would be nice to have the inner text be available in the partial as
a locally scoped variable (for example innerText).
The thing about that which struck me is how similar the partial files and the monorail view components would become at that point. When a monorail view component is used one of the things it can to is render the child contents which are contained on the original file. Many user controls, like panel, can do the same thing.
Read the rest of this entry »
Tagged internet, opensource, programming, spark. Posted in spark
Here’s a great post from Torkel Ödegaard. In it he says:
This is the view engine I have been looking for! I quickly downloaded the latest release, referenced the spark assembly from my MVC application and was testing it in a matter of minutes. After reading though the documentation I was able to convert all my WebForms views into spark views in just an hour (so far very small application with not many views).
I find this a lot easier to read and understand than the html/<% %>/C# tag soup that is sometimes hard to avoid with WebForms. I also think a view engine like this make more sense, because Spark is a view engine tailor made for only one thing, to generate html!
He’s also provided some feedback in the discussion group and reported a problem in the trac ticketting system. Actually there’s a few people have done that already. It’s great to see a sort of community coming together providing ideas and feedback.
Other interesting discussion groups exist for Asp.Net MvcContrib, and for Castle Project, but I didn’t want to spam them with too many Spark topics. So if you’re looking into the view engine please feel free to join the Spark group if you have any questions or suggestions.
Tagged development, internet, programming, spark. Posted in spark
I mentioned in an earlier post that I’d recently hit a milestone in getting past a lingering fear of flying. Thanks to Jamie also for the words of encouragement. It turns out it wasn’t a minute too soon. Not two weeks later I find myself back in New York.
Which was an interesting and uneventful trip. And then comes Wednesday night as I leave the office at 5 eastern time for La Guardia - when I show up the electronic check-in informs me the flight I’m on has been canceled. It does however print out a pair of replacement tickets for a connecting flight in Indianapolis leaving at 8:30. Plus a receipt to pick up a “we’re sorry” kit of some sort.
At the gate I learn two things. a) The flight leaves at 8:30 a.m. the next morning and b) the sorry kit consists of a discount on the next flight. Not a hotel voucher or anything. Yay! Another night in New York!
Read the rest of this entry »
Tagged airlines, new york, rant, travel. Posted in Uncategorized, rant
The Weekly Source Code 30 to be specific, by Scott Hanselman.
I’ve been followed Hanselman now for a while and had the opportunity to see him in person at mix08 presenting a session on Asp.Net MVC. He’s a funny guy and a great speaker.
So that’s pretty cool. I’m glad he liked how Spark came together.
Tagged hanselman, internet, opensource, programming, spark. Posted in spark
There are a bunch of updates related to Spark so I think I’ll just run through them in whatever order.
First, the documentation and downloads area have moved to a Drupal cms at http://dev.dejardin.org instead of using the Trac site’s built-in wiki.
There’s a new release of Spark view engine available on the download page.
The first thing to watch out for is a breaking change: support for the $expression; syntax has been removed due to collisions with normal prototype and jquery usage. Anyplace that was using that syntax will need to change to ${expression} but beyond that any valid csharp expression still works to produce output.
Another requested change from Tim Schmidt has been made to support single-quoted string literals when csharp appears in a spark file. That’s to allow xml attributes to use double quotes even though they contain expressions. For example, the code below that writes out a string if a product is in stock:
<ul>
<li each="var product in Products"
class="${product.Quantity != 0 ? 'instock' : 'outofstock'}">
${product.Name}
</li>
</ul>
The quotes are changed when the generated class is produced. The generated class contains the following:
Output.Write(product.Quantity != 0 ? "instock" : "outofstock");
An even more significant enhancements has been made to the conditional syntax. This is based on some excellent feedback and ideas from Pablo Blamirez a few weeks back.
<test if="!user.IsLoggedIn">
<p>Please sign in.
${Form.FormTag(new {controller="account", action="login"})}
user ${Form.Textbox("user")} pass ${"you get the idea..."}
${Form.EndFormTag()}
</p>
<else if="user.IsAdministrator"/>
<p>Administrator ${user.Name} etc.</p>
<else/>
<p>Hello, ${user.Name}.</p>
</test>
Note the empty <else/> elements. The previous formats are still supported, so you could use <if condition=""> instead of <test if=""> and the else elements may also be used in a way where they follow the original test. So the following is equivalent.
<test if="!user.IsLoggedIn">
<p>Please sign in.
${Form.FormTag(new {controller="account", action="login"})}
user ${Form.Textbox("user")} pass ${"you get the idea..."}
${Form.EndFormTag()}
</p>
</test>
<else if="user.IsAdministrator">
<p>Administrator ${user.Name} etc.</p>
</else>
<else>
<p>Hello, ${user.Name}.</p>
</else>
In the end it’s a stylistic preference.
Tagged geek, internet, opensource, programming, spark, tech. Posted in spark