Idea: common template syntax

533 views
Skip to first unread message

Dracony

unread,
Apr 1, 2016, 3:57:39 AM4/1/16
to PHP Framework Interoperability Group
Ok, so this is exactly what it sounds, a generic syntax for templating that would specify a basic limited subset of operators (e.g. foreach, if, else). Basically an extended version of Mustache.

This sounds really weird, because usually syntax is the defining feature of a templating engine, so it feels wrong to come up with a generic one. But think of the possibilities:
  • Language agnostic syntax would also allow rendering with js
  • Easy to upgrade from one engine to another (people who have ported sites from Smarty to Twig know what I mean)
  • Unlike logicless Mustache we can add features such as comparisons and other asy to implement operators that allow some logic
The important featres that must be in:

  • Outputting (wee obviously)
  • foreach loop
  • if/elseif/else
  • ternary operator
  • regular for loop
  • includes
  • layouts
  • blocks
  • native calls (e.g. raw php code to eval)
Like the idea? If so, I can totally pick this up!

Alexander Makarov

unread,
Apr 1, 2016, 9:05:00 AM4/1/16
to PHP Framework Interoperability Group
Idea is OK but is out of scope of the group, I'm afraid.

Mathew Whitney

unread,
Apr 13, 2016, 11:04:10 AM4/13/16
to PHP Framework Interoperability Group
The allowance for native calls would seem to conflict with the idea of a language-agnostic syntax. I think a lot of PHP and/or JS template systems are just reinventing XSL/XSLT (knowingly or in ignorance) in a syntax which is more palatable to the developers of those systems, which would also lead me to suggest looking at XSL, if not as a solution, then at least as an example of some of the things which do and don't work in terms of a generic syntax for templating.
Reply all
Reply to author
Forward
0 new messages