1.0.13 • Published 4 years ago

ejs-render-remote v1.0.13

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

ejs-render-remote

ejs remote client side includes.

html = ejs.rr('sayhello.ejs', {name: 'Simon'});

Quick start

  1. Install with npm i ejs-render-remote
  2. Include this script
    <script src="node_modules/ejs-render-remote/ejs-render-remote.js"></script>
  3. Create a file with your template, for example templates/hello-world.ejs containing hello <%= name %>!
  4. Render the remote template:
    someDomelement.outerHTML = ejs.rr('templates/hello-world.ejs', {name: 'Simon'});

Examples

See examples folder.

api

ejs.rr(templateUrl, data)

ejs.rr (render remote) renders the remote template. It makes an ajax call to fetch the template and then ejs.renders it.
The resulting ejs template function is cached, so the second time this function is invoked for that same template, ejs.rr returns the rendered template synchronously.

ejs.preloadTemplate(templateUrl)

Since ejs.rr is async, you can call ejs.preloadTemplate before invoking ejs.rr to warm the template cache up for that templateUrl.
By doing so the call to ejs.rr will return the rendered template string right away.

1.0.13

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.12

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago