Search code examples
node.jstwigtemplate-engineejs

ejs template engine, extend parent to form a decent design pattern


With the templating system twig you can extend a parent template with the extends function.

I am just starting out with node and having a go with the ejs template engine but cannot find similar functionality. Does anyone know if this is possible with ejs, and if not is there a js tpl engine that can extend a parent?

I want to build a simple tpl structure eg:

<pagelayout.ejs>
  <publicHeadScripts.ejs />
  <pageBodyBlock>
  <publicFooter.ejs />
</pagelayout.ejs>

But multiple routes will require this tpl structue and i don't want to have to include all the above files all the time. EG /coolpage would route to but this itself would be injected into the above "pageBodyBlock".

Thanks in advance, John


Solution

  • I found the answer, there is a port of twig... it goes by the name of swig :)

    http://paularmstrong.github.io/swig/

    It is awesome!