1.0.3 • Published 7 years ago
larvitviews v1.0.3
Larvitviews
Templating wrapper for lodash templates, adding support for partials and hierarchy.
When we selected template driver we had the following requirements:
- All HTML should reside in the templates and nowhere else. This is not debatable.
- It should resemble HTML as much as possible. Especially since the front enders normally just know HTML/CSS/js. It should not be a totally "new" language. This issue have been a burden in the past for us, for example when we used XSLT.
- It should be fast. Really fast.
Used as the "view" part of the MVC micro framework larvitbase.
Usage
Template file /public/tmpl/test.tmpl:
<p>Hello <%= user %></p>
Javascript file:
const views = require('larvitviews')(),
data = {'user': 'Lilleman'};
console.log(views.render('test', data)); // <p>Hello Lilleman</p>
Full documentation on the upstream Lodash templates.
Template partials
Template file /public/tmpl/foo.tmpl:
<h1>Boo</h1>
<p><%= _.render('bar', obj) %></p>
Template file /public/tmpl/bar.tmpl:
Value is: <%= obj.value %>
And to render this write this javascript code:
const views = require('larvitviews');
console.log(views.render('foo', {'value': 'rev'}));
// Renders:
// <h1>Boo</h1>
// <p>Value is: rev</p>
1.0.3
7 years ago
1.0.2
9 years ago
1.0.1
9 years ago
1.0.0
9 years ago
0.3.0
9 years ago
0.3.0-rc
9 years ago
0.2.1
9 years ago
0.2.0
9 years ago
0.1.4
9 years ago
0.1.3
10 years ago
0.1.2
10 years ago
0.1.1
10 years ago
0.1.0
10 years ago
0.0.11
10 years ago
0.0.10
10 years ago
0.0.9
10 years ago
0.0.8-beta
10 years ago
0.0.7-beta
10 years ago
0.0.6-beta
10 years ago
0.0.5-beta
10 years ago
0.0.4-beta
10 years ago
0.0.3-beta
10 years ago
0.0.2-beta
10 years ago
0.0.1-beta
10 years ago