ejs
ejs copied to clipboard
a tag for template literals
I use ejs a lot in the browser only, and it would be really cool if we could use template strings to store ejs templates. Something like
var name = 'Simon';
var html = ejs`
<div>
<p><%= name %></p>
</div>
`;
Editors like vscode could then be extended to support syntax highlighting to ejs template literals like lit-html does.
I made an example of how this could work: https://github.com/S2-/ejs/blob/template-literal/examples/client-template-literals.html#L31
Using template literals there would be no need to make <script type="text/ejs"> elements in html, and it would come in handy when making js libraries that have templates inside them and are shipped without having a server side component.