Permalink
Browse files

Merge pull request #14 from axelpale/patch-1

Added instructions on implementing nested templates
  • Loading branch information...
2 parents e6773f9 + 96d9b73 commit c76794e9729c43a5700bfeaf5a33ca1fee3c61be @okonet 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 c76794e

Please sign in to comment.