mde / ejs

Embedded JavaScript templates -- http://ejs.co
Apache License 2.0
7.69k stars 841 forks source link

a tag for template literals #365

Open 5im-0n opened 6 years ago

5im-0n commented 6 years ago

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.

5im-0n commented 6 years ago

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.