What are the main differences between StringTemplate and FreeMarker?

前端 未结 2 741

The net seems to be full of comparisons between Velocity and FreeMarker, and they seem to be reasonably equivalent. But there seems to be almost no comparisons between StringTem

相关标签:
2条回答
  • 2021-02-03 22:08

    The main difference is that StringTemplate strictly enforces model-view separation and you can't put logic in the templates and FreeMarker lets you put full of logic in the templates.. This at least at the beginning make it more difficult to use but it's more scalable. For example if you are generating code and you have no logic in the templates generating another port for another language is less tedious because you haven't to replicate logic in each template.

    There's a paper from Terence Parr that explains the benefits from model-view separation

    0 讨论(0)
  • 2021-02-03 22:11

    I designed ST to build jGuru after getting sick of the "code in template" model of JSP. Velocity and friends (i.e., every other engine i think) give you more power than you need. I used basically four features to build jGuru.com (as described in paper). More features are unnecessary and lead you to entangle your model into the template. If you're building a one-off prototype, that's ok and any engine is fine. Code in templates is ok in that case since you don't care about maintenance.

    Another thing people seem to ignore: how the hell can a graphics designer read code in templates? They can't. So, how can they work on the templates then? Even changing the order of some elements can break your model. You really need the separation to work in commercial environment, unless you want a site that looks like a coder built the html ;)

    0 讨论(0)
提交回复
热议问题