1.0.3 • Published 6 years ago

larvitviews v1.0.3

Weekly downloads
34
License
MIT
Repository
github
Last release
6 years ago

Build Status Dependencies

Larvitviews

Templating wrapper for lodash templates, adding support for partials and hierarchy.

When we selected template driver we had the following requirements:

  1. All HTML should reside in the templates and nowhere else. This is not debatable.
  2. 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.
  3. 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

6 years ago

1.0.2

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.3.0

8 years ago

0.3.0-rc

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.11

9 years ago

0.0.10

9 years ago

0.0.9

9 years ago

0.0.8-beta

9 years ago

0.0.7-beta

9 years ago

0.0.6-beta

9 years ago

0.0.5-beta

9 years ago

0.0.4-beta

9 years ago

0.0.3-beta

9 years ago

0.0.2-beta

9 years ago

0.0.1-beta

9 years ago