I need a templating mechanism for html-pages bundled with my app. At first I looked at all the javascript templating solutions (like jQuery templates), but since my input data is XML, I suddenly remembered XSLT again. I came across tens of libaries, but none seemed to make use of XSLT, so I completely forgot about its existence, and how useful it is for creating templates.
So, is XSLT slowly deprecated and phased out by javascript alternatives? I read somewhere XSLT was too complicated for most users to work with, but is that its only downside or are there more cons?
Update: I can think of only one disadvantage myself: with XSLT the complete page has to be parsed/rendered before displaying anything to the user, and with the javascript the page is already visible and the missing elements are filled afterwards.
XSLT is a good solution for templating. The language and syntax are a bit unusual — “choose/when” instead of “case/switch” is a glaring example — but it does its job well.
XSLT’s main advantage is that you don’t need JavaScript to use it; build it right and every major browser will render it as HTML whether JS is enabled or not. It may be easier on the processor than JavaScript solutions, although I don’t know anyone who’s tested this. It’s also the obvious choice if you’re already dealing with XML data, as you are.
The downside is that it’s a (relatively) old technology which has been largely abandoned, and while browsers still support it, they haven’t moved forward with it. Firefox has an issue with HTML escaping that they have no intention of fixing, and Chrome has a pretty major problem with @includes. IE is apparently up-to-date, but that of course only applies to the latest version.
The upshot is that if you want to use XSLT, you have to test it in all your major browsers and work around the bugs, despite the fact that the technology has been around since at least 2006. It is by no means deprecated, it’s just not very popular because it’s not as compact or easy to read as, say, JSON + jQuery templates.