views:

55

answers:

2

I have a service that receives an object containing all the data needed to build a newsletter. I need to be able to generate the email using different templates. I don't want to involve the whole ASP.NET stack for that, so I want a separate templating engine.

Reading a lot of opinions, I have found that XSLT was not getting very much love when it comes to templating engines. Why?

SparkViewEngine is a "new cool toy", but it seems mature enough considering the number of projects that have been built with it. What do you think?

Did you used those 2 engines? in which situation, and what strength/pain did you enjoy/endure

+2  A: 

XSLT is much more verbose, especially when it comes to tricks like conditional attributes. I used it a lot (even to generate C#/C++ source code) but I don't remember that time to be a joy. Spark is.

queen3
That's just what I ask in my questions... "I have found that XSLT was not getting very much love when it comes to templating engines. Why?"The Why is really what I am looking for :)Since you used both frameworks, is it really a pain to work with?
Stephane
I actually answered exactly this question. If language being too verbose (way too verbose) doesn't bother you, go ahead and use XSLT. I consider it a pain when I have to write more auxiliary tags than meaningful content. This is the Why. Spark tries to reduce verboseness in its every construct, and I enjoy using it. I would never, ever, consider using XSLT unless I have to.
queen3
Thanks for sharing your experience :) It comforts me in our choice and we start building our templates using spark now :)
Stephane
+1  A: 

I used a Spark template to generate an email on my last project, it was a fairly straight forward experience.

As you mentioned you have an object containing all the data needed to build a newsletter. To use XSLT wouldn't you need to serialize to to XML first? Using Spark skips the serialization step and gets you directly to the output you want, and as queen3 mentioned, creating conditional attributes is quite easy.

In case you need it, there's a post on how to use Spark as a general purpose templating engine here.

Also if you have to work with any graphics designers it may be easier to take an HTML mockup and turn it into a spark template than it would be taking an HTML mockup and turning into an XSLT.

R0MANARMY
thanks! I already read that post, I actually already built a proof of concept that is generating an output using spark within a console app.I am more looking for positive/negative points of both engines to be able to explain the choice.
Stephane
@Stephane: Even better, then yeah, ignore everything besides saving an intermediate XML serialization step. Also if you have to work with any graphics designers it may be easier to take an HTML mockup and turn it into a spark template than it would be taking an HTML mockup and turning into an XSLT.
R0MANARMY
that's a valid point. we will have clients giving us email mockups that we will have to turn into a template.
Stephane
No, I said conditional attributes, like attr="?{value}", IIRC. Conditional tags are not problem in XSLT, but conditional attributes means using XSLT syntax to construct tags by hand (awkward).
queen3
@queen3: Fixed.
R0MANARMY