mirror of
https://github.com/S2-/ejs-render-remote
synced 2025-08-02 12:40:04 +02:00
initial commit
This commit is contained in:
31
README.md
Normal file
31
README.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# ejs-render-remote
|
||||
|
||||
[ejs](https://ejs.co/) remote client side includes.
|
||||
|
||||
## Quick start
|
||||
|
||||
1. Include this script
|
||||
```html
|
||||
<script src="node_modulse/ejs-render-remote/ejs-render-remote.js"></script>
|
||||
```
|
||||
2. Creare a file with your template, for example `templates/hello-world.ejs` containing `hello <%= name %>!`
|
||||
3. Render the remote template:
|
||||
```js
|
||||
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.render`s 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 chace up for that `templateUrl`.
|
||||
By doing so the call to `ejs.rr` will return the rendered template string right away.
|
Reference in New Issue
Block a user