Permalink
Browse files

Added instructions on implementing nested templates

  • Loading branch information...
1 parent e6773f9 commit 96d9b73fa9f515f8d621189b549337a872714000 @axelpale axelpale committed on GitHub Sep 11, 2016
Showing with 23 additions and 0 deletions.
  1. +23 −0 README.md
View
@@ -86,6 +86,29 @@ module.exports = {
};
```
+
+### Including nested templates
+
+Lodash template function does not provide `include` method of [ejs module](http://ejs.co/). To include other templates, passing template functions as parameters does the job. For example:
+
+**index.js:**
+
+ var mainTemplate = require('ejs!./main.ejs');
+ var hyperlinkTemplate = require('ejs!./hyperlink.ejs');
+ var renderedHtml = mainTemplate({ hyperlink: hyperlinkTemplate });
+
+**main.ejs:**
+
+ <h1><%= hyperlink({ name: 'Example', url: 'http://example.com' }) %></h1>
+
+**hyperlink.ejs:**
+
+ <a href="<%= url %>"><%= name %></a>
+
+As a result, `renderedHtml` becomes a string `<h1><a href="http://example.com">Example</a></h1>`.
+
+
+
## Release History
* 0.3.0 - Allow passing template options via `ejsLoader` or via loader's `query`
* 0.2.1 - Add ability to pass compiller options

0 comments on commit 96d9b73

Please sign in to comment.