mde / ejs

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

Is there a way to use ejs on the front-end? #752

Closed socreative closed 4 months ago

socreative commented 4 months ago

I am looking to use a JS based templating on the front-end and I used ejs with Node but is there a way to use EJS on the frontend? I am getting TypeScript compiler errors with trying to use in in Angular as ejs relies on node processes.

AnshSinghSonkhia commented 4 months ago

You have to fetch and render your EJS code in Angular, as of what I remember of the time when I used it.

And, this will be achieved using HttpClient from '@angular/common/http' and Component & OnInit from '@angular/core'

socreative commented 4 months ago

i was just thinking i could have the template as a string and use the EJS render() method, but i cant even import EJS to use it. it references node's fs and process which dont exist on the frontend

RyanZim commented 4 months ago

@socreative browser-compatible builds can be downloaded from https://github.com/mde/ejs/releases/