« Efficiently doing... stuff... using .NET delegates | Main | About the Authors: Rob Huffstedtler »



Feed You can follow this conversation by subscribing to the comment feed for this post.

Scott LEwis

Aaron, I can certainly see the usefulness of JSTemplating. I wonder, though, what are your thoughts with regards to the impact on the document semantics?

Aaron Romine

That's a very good question.

Obviously the first impact is that meaning is being transferred from context to client side templates. Loosing that context means your page is less machine readable - and that most of your 'content' lives (presumably) in AJAX calls. This is true however with anything dynamically written. I think the strengths of this approach to templating lies in developing a richer UI more quickly. Providing fallback and accessibility as well as machine accessible semantics is a lot to tackle while maintaining a rich UI.

If your looking at it from a more correctness approach (e.g. using a script tag to hold page mark-up), that is somewhat troublesome. The script tag's type attribute works just like any other mime-type attribute - telling the browser how to process the content's of the tag. The assumption is that a browser won't evaluate a script tag with a 'type' of 'text/html' since it doesn't have a script engine for that mime type. This has desired 'ignore' effect in every major browser I've tried. So from a pragmatic point of view - it works, and is somewhat more elegant than placing them in div's or JS literal strings. That being said it's using the script tag in a way it wasn't meant to be used (at least directly). If you think about it, the content of the tag is still script related, but the original semantics aren't the same. What it accomplishes is a way to have the browser completely ignore the contents of the node. This is extremely helpful when writing templates, as the content of the node may or may not be valid HTML, and mostly definitely isn't desired to be displayed without being evaluated.

Of course this whole approach has it's ups and downs. Most of the templating solutions I've reviewed rely on innerHTML as a setter, which has some major limitations (for instance: tables). I usually resort to using the DOM (slow but it's getting faster and faster). I'll have to look around for some of my old code that used a JSON syntax for creating templates. Not nearly as natural as straight up markup - but much more flexible.


Do you think Jon Resig's solution is production-ready or just a clever experiment? Also, do you see this type of solution becoming obsolete or unnecessary once client-side storage is supported by all of the major browsers?

The comments to this entry are closed.


Contact ICF Interactive

  • ICF Interactive a full-service, interactive agency with the ability to guide brands digitally – through an informed strategy, inspired design, technical know-how and an obsession for humanity, we not only can launch your site but we can digitally catapult your brand. If you have a project in mind, would like information regarding our work, career opportunities, proposal requests or anything else, please feel free to get in touch. We’re ready for what’s next. hello@icfi.com