Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turing complete template engines [closed]

What template engines / template languages are turing complete? I heard about these so far:

  • FreeMarker (implemented in java)
  • MovableTypes template language (in perl)
  • xslt :-(
  • Cheetah (in Python)
  • Smarty (in PHP)

Any others (especially implemented with perl)?

Ps: Don't waste time with clarifying me MVC, and why turing complete templates are bad, and why this is not a useful comparison point :)

like image 362
jm666 Avatar asked Jun 15 '11 00:06

jm666


2 Answers

Perl's Template::Toolkit allows for inlining of Perl if the EVAL_PERL flag is set. Within the template, PERL and RAWPERL blocks allow inlining, to the extent (in the case of RAWPERL) that the internals are exposed, and inlined code is evaluated through eval() (the quoted eval). This provides full access to the Perl interpreter.

Perl is itself considered to have a Turing Complete grammar. So given that Template::Toolkit does provide access to Perl itself, the templating system inherits that characteristic.

Though setting EVAL_PERL to allow for inlined Perl within a template is considered an advanced (and presumably seldom-used) feature, it is available for the strong-hearted (and questionably-sane).

like image 151
DavidO Avatar answered Sep 21 '22 22:09

DavidO


eRuby lets you embed arbitrary Ruby into your templates:

$ echo "Hello <%= 'dlrow'.reverse() %> from eRuby" | erb
Hello world from eRuby
like image 39
sarnold Avatar answered Sep 19 '22 22:09

sarnold