1

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?

  • I found out that the template engine is EJS and the app in question had modified the default syntax to use square brackets instead of the typical <% ... %> syntax. – sealocal Aug 4 '15 at 7:07
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 Jul 28 '15 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 Jul 28 '15 at 7:10
  • I've found that question, too. I've only seen references to the <% ... %> syntax, not [[ ... ]] syntax. – sealocal Jul 28 '15 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.