ejs-electron icon indicating copy to clipboard operation
ejs-electron copied to clipboard

Add option for custom tags

Open tarutin opened this issue 7 years ago • 1 comments

Hi! How can I modify custom open/close tags? <%= key %> to {{= key }}?

tarutin avatar Nov 26 '17 23:11 tarutin

It looks like recent versions of ejs removed support for the open and close options. There's a discussion going on to re-implement them here with relevant pull request here.

In the meantime, there is the delimiter option that you can use with ejs-electron like so:

const ejse = require('ejs-electron')

ejse.options('delimiter', '?')

Unfortunately, the delimiter only controls the inner character(s) of the ejs tags (e.g. the % signs in <% %>). This would make mustache-style tags pretty awkward (e.g. with delimiter {, you'd end up with <{ and {> as your basic tags... so that's unfortunate).

From ejs-electron's perspective, it might be possible to run regex on the stringified contents of an ejs file and replace custom open/close tags with the standard <% and %> ejs tags. I would be very hesitant to do this as it seems error-prone and would certainly be non-performant.

For now you're probably better off pushing for/contributing to that ejs pull request.

bowheart avatar Nov 27 '17 03:11 bowheart