By @angrykoala
eXtreme EJS
XEJS allows you to render files with a custom tag-based language using EJS
Recursive templating, what could go wrong?
xejs provides a custom renderer utility on top of ejs, allowing you to define your own tags of the type {{my tag }} with custom delimiters (<< my tag >>).
xejs will then match your custom regex rules (e.g. /[Tt]itle/) and map it to a string to be rendered by ejs.
The original EJS tags of the file (<% %>) will be escaped and won't be rendered by xejs
varxejs=require('xejs');varfs=require('fs');varoptions={openTag: "{{",closeTag: "}}",tokens: [[/bold\s(.+)/,"- '<b>$1</b>'"]]};varfile=xejs("example/test.ejs",options);fs.writeFileSync('example/prueba.html',file);This code will render all{{bold [my text] }} into html <b> text
The tag include is already implemented, allowing you to load (and render) another file.
Using the tags delimiters {{... }}
/[Tt]itle/-"= title"will translate any tag of the type{{title }}or{{Title}}into a valid<%- title %>ejs tag which will be rendered by ejs.
Warning: Only simple tags allowed, nested tags and html-based tags not supported