Questions tagged [template-engine]

A template engine is software that is designed to process templates and content information to produce output documents.

A template engine is software that is designed to process templates and content information to produce output documents, for example:


Paul Sweatte, in an answer to a now-deleted question, provided the following resources on the evolution of separating content from presentation and insights on the historical evolution of template engines:

The W3 Word Processor Filters page is essential reading that should cover most of the basics. For more details, here some resources on the evolution of separating content from presentation:

Markup and typesetting languages are the earliest examples of templating.
Here is the Wikipedia definition:

A markup language is a modern system for annotating a document in a way that is syntactically distinguishable from the text. The idea and terminology evolved from the "marking up" of manuscripts, i.e., the revision instructions by editors, traditionally written with a blue pencil on authors' manuscripts. Examples are typesetting instructions such as those found in troff and LaTeX, or structural markers such as XML tags.

Here is a diagram:

                RUNOFF                      "Generic Coding"                 "Editorial Structure Tags"
           (Jerome Saltzer, 1964)         (William Tunnicliffe, 1967)          (Stanley Rice, pre-1970)
                    |                               |                                     |
                    |                               |                                     |
TeX          roff - nroff - troff                   |-------------------------------------|  (Don Knuth, 1977)   (Josef Osanna, 1973)                   |
                                                   GML
                                            (Charles Goldfarb, 1969)
                                                    |                       SCRIBE
                                                    |                   (Brian Reid, 1980)
                                                    |                          |
                                                    |--------------------------|
                                                  SGML
                                              (Standard, 1980)
                                             |                |
                                             |                |
                                           HTML              XML
                                    (Berners-Lee, 1990)    (Standard, 1998)

As far as web site templating, SSI is the mother of them all.

1649 questions
36
votes
7 answers

Escape double braces {{ ... }} in Mustache template. (templating a template in NodeJS)

I'm trying to template a template, like below: {{{ { "name" : "{{name}}", "description" : "{{description}}" } }}} {{{debug this}}}

{{name}}

Where I want to triple brackets to stay, but double brackets to be replaced with the JSON…
Nick Jonas
  • 1,197
  • 4
  • 13
  • 24
35
votes
3 answers

Handlebars, loading external template files

My goal is to put all my Handlebars templates in a single folder, as so: templates/products.hbs templates/comments.hbs I found this snippet in a few places via a cursory Google search, which apparently will load in Handlebar templates in external…
CaptSaltyJack
  • 15,283
  • 17
  • 70
  • 99
35
votes
3 answers

Is it considered bad practice to use HTML in Jade?

Jade looks like a cool templating engine and I think I'll be using it for my next project. However, some of the syntax doesn't make sense to me. What do you get by doing this: ul li a(href="#book-a") Book A instead of:
35
votes
5 answers

Jinja 2 safe keyword

I have a little problem understanding what an expression like {{ something.render() | safe }} does . From what I have seen, without the safe keyword it outputs the entire html document, not just the true content. What I would like to know, is what…
coredump
  • 3,017
  • 6
  • 35
  • 53
34
votes
5 answers

Dealing with an empty list in mustache.js

I'm using mustache.js to render a template in javascript. I'd like to check if a list is empty or not to hide the

tag in the following example. Is this possible or is mustache.js too logic-less? This is the template:

Persons:

Max Schmidt
  • 7,377
  • 5
  • 23
  • 29
34
votes
1 answer

RythmEngine and TemplateClassManager the Biggest Objects of the heap : memory leak problems

In my company, we are using Rythm due to its facility and easy use in a project. In our project, we are sending several e-mails (1000-2000 emails by day); the e-mail template is a Rythm template with dynamic syntax (Java code). Performance seems…
33
votes
5 answers

Jinja2 round filter not rounding

I have the following code in my template: data: [{% for deet in deets %} {{ deet.value*100|round(1) }}{% if not loop.last %},{% endif %} {% endfor %}] I am expecting data rounded to 1 decimal place. However, when I view the page or source, this is…
Mittenchops
  • 18,633
  • 33
  • 128
  • 246
32
votes
4 answers

Which templating engine can I use with both JS and PHP?

I'm looking for a simple Template engine that works both on client side with JS ánd on server side with PHP. That means I want to be able to use the same template definition for both use cases. Do you know any templating engines that have official…
Florian
  • 3,145
  • 1
  • 27
  • 38
31
votes
5 answers

Extending or including - what is better in Twig?

Why Twig documentation recommends to use extending rather than including? Symfony 2 documentation says because "In Symfony2, we like to think about this problem differently: a template can be decorated by another one." but nothing more. It's just…
Isinlor
  • 1,111
  • 1
  • 13
  • 22
30
votes
2 answers

Email Internationalization using Velocity/FreeMarker Templates

How can I achieve i18n using a templating engine such as Velocity or FreeMarker for constructing email body? Typically people tend to create templates like:

${message.hi} ${user.userName}, ${message.welcome}

${message.link}
adarshr
  • 61,315
  • 23
  • 138
  • 167
30
votes
6 answers

What is the best code template facility for Emacs?

Particularly, what is the best snippets package out there? Features: easy to define new snippets (plain text, custom input with defaults) simple navigation between predefined positions in the snippet multiple insertion of the same custom…
jfs
  • 399,953
  • 195
  • 994
  • 1,670
30
votes
1 answer

What kind of a solution is thymeleaf?

I read that thymeleaf is preferred instead of JSP nowadays. Which problem does thymeleaf solve that JSP can't? How is thymeleaf compared to other templating engines?
Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424
30
votes
4 answers

Default value for a Handlebars` template placeholder

Can I specify a default value for a Handlebars` template placeholder?