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
0
votes
1 answer

Ruby template engine that looks like ruby syntax

I believe i've seen a template engine that uses ruby-like syntax, such as: some_variable = 'bla bla' res = div id:'yay' { button onclick: 'test()', class: 'btn btn-primary btn-xs' p some_variable } # generates: #
#
Kokizzu
  • 24,974
  • 37
  • 137
  • 233
0
votes
0 answers

How to truly separate template from code?

I have a conundrum here, and I apologize for not being able to just copy and paste code as it's internal corporate stuff. I'll try to explain the best I can without showing code. Let's say I have a Handlebars page full of HTML and some light logic…
CaptSaltyJack
  • 15,283
  • 17
  • 70
  • 99
0
votes
2 answers

How to make so that Jade (Node.js) doesn't close the tag

I'm trying to send multiple chunks of data to a client each of which is rendered by Jade templating engine in Express Node.js framework. I have several views like header, viewA, viewB, viewC, etc. For every request I need to render the header…
esengineer
  • 9,514
  • 7
  • 45
  • 69
0
votes
1 answer

image doesn't load when using template inheritance

The image in the parent template doesn't load in the child one, instead it shows the 'alt'. Here's how the structure goes. "base.html"
Shimaa
  • 477
  • 1
  • 6
  • 16
0
votes
1 answer

Client template engines : Dust's performance

I have created a test cases for comparing the performance of different template engines. Here my test case link : http://jsperf.com/dust-hogan-handlebar-ejs-underscore I've noticed Dust.js's performance and so surprise with that result. I have…
kate
  • 179
  • 2
  • 16
0
votes
1 answer

Best practice to eliminate blank lines in HTML due to templating engines

Blank lines within and especially at the top of an HTML source file look untidy to me. A common template code (in this case, Jinja2) may look like this: {% block header %} {% include "templates/partials/something_header.html" %} {% endblock header…
ljs.dev
  • 4,449
  • 3
  • 47
  • 80
0
votes
0 answers

Echoing from a class to template system

I use a template system which is little bit similar to MVC. It uses .tpl files for outputing html. And I am trying to use a comment class with it. for example you create comments.tpl
Erdem Ece
  • 1,755
  • 5
  • 22
  • 42
0
votes
1 answer

smarty: better let it doing the hard part or better serving it php-precompiled html?

I was wandering.. If, say, I have to build a menu, or say, a group of specs sheets based on an array of product data.. In other words, if I have to render an array, what is better (from a performance point of view): a. build all the html in php (say…
Luca Reghellin
  • 7,426
  • 12
  • 73
  • 118
0
votes
2 answers

PHP Template engine regex

I'm trying to write a PHP template engine. Consider the following string: @foreach($people as $person)

$end I am able to use the following regex to find it: @[\w]*\(.*?\).*?@end But if I have this string: @cake() @cake() …
Petter Thowsen
  • 1,697
  • 1
  • 19
  • 24
0
votes
4 answers

Regular expression for template engine?

I'm learning about regular expressions and want to write a templating engine in PHP. Consider the following "template":
Petter Thowsen
  • 1,697
  • 1
  • 19
  • 24
0
votes
1 answer

PHP Template Engine built by url

I am searching for a kind of dynamic template engine which I want to built by the url. So if my url is like localhost/root/this/is/the/path/to/signup.php the php code should watch for the file signup.php in the directory this/is/the/path/to/ For…
0
votes
2 answers

Difference between ${startDate} and #= startDate # in Kendo UI binding?

When binding to templates, many examples use the following syntax: ${startDate} and #= startDate #. There does not seem to be a difference and the use is inconsistent. The docs does not shed any light on this. Which one is recommended and is there a…
TruMan1
  • 33,665
  • 59
  • 184
  • 335
0
votes
3 answers

Iterate through arbitrary json in backbone/underscore template

In the normal case you get the value via the key, that is to get the value of name with <%= name %>, you have to know the key is "name". My question is if you do not know the key of the json field in the first place, how can you iterate through…
spacemilkman
  • 943
  • 1
  • 9
  • 15
0
votes
1 answer

PHP Template class / engine processing time

I want to learn a bit more about OOP within PHP. So i decided that i would build my own MVC framework and a simple application running on this framework. There are a lot of great tutorials out there on this thing called the world wide web but most…
rofavadeka
  • 577
  • 6
  • 19
0
votes
3 answers

Templating different languages in a PHP webapp

I'm writing a webapp in german, so all buttons,text,tooltips etc. are in german for now. But I want to use some kind of template file for the webapp so I can quick change to another language if needed. I thought about textfile that I explode with…
Johnny000
  • 2,058
  • 5
  • 30
  • 59
1 2 3
99
100