I'm looking at the source code for a Rails application that uses Backbone and there are template files with .jst.ejs
extensions.
The templates include HTML with lines of JavaScript wrapped in double-square-brackets like this this example:
[[ if (currentUser) { ]]
<h1>Welcome, back!</h1>
[[ } else { ]]
<h1>Please sign up!</h1>
[[ } ]]
What is the name of this template syntax?
1 Answer 1
I'm not sure if many template syntaxes have a specific name. A lot of template syntaxes are unique, but there are frameworks out there that use similar templating syntaxes without actually calling them anything. Mostly, they are referred to by the name of the engine.
For example, both Twig (a templating engine that can be used with the Symfony Framework for PHP) and AngularJS (a javascript Framework) have ways of binding by means of the {{ }} syntax. A code sample could be said to be using a Twig-like or Angular-like syntax, but as far as I know there are very few templating syntaxes out there that are standardized and implemented in different engines and can therefore be 'named'.
-
To follow up on that info, does it make sense to ask what templating engine utilizes the [[ ]] syntax?sealocal– sealocal2015年07月28日 00:17:30 +00:00Commented Jul 28, 2015 at 0:17
-
Would be more appropriate for stackoverflow I think, but go ahead. Might be a custom thing though. The extension of the file could put you in the right direction, is stackoverflow.com/questions/6557238/… any help?JDT– JDT2015年07月28日 07:10:27 +00:00Commented Jul 28, 2015 at 7:10
-
I've found that question, too. I've only seen references to the
<% ... %>
syntax, not[[ ... ]]
syntax.sealocal– sealocal2015年07月28日 18:05:53 +00:00Commented Jul 28, 2015 at 18:05
<% ... %>
syntax.