Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ <h2>Template Languages <span>(alphabetical)</span></h2>
<li><a href="https://github.com/paularmstrong/swig">Swig</a> - Swig is a template engine inspired by the Django syntax.</li>
<li><a href="https://github.com/constantology/Templ8">Templ8</a> - JavaScript client/server template engine.</li>
<li><a href="https://github.com/gsf/whiskers.js">Whiskers</a> - A mustachioed templating library.</li>
<li><a href="https://github.com/cho45/micro-template.js">micro-template</a> - A template engine on JavaScript which like embed js.</li>
</ul>

</header>
Expand All @@ -60,6 +61,7 @@ <h2>Feature Comparisons</h2>
<th scope="col">Swig</th>
<th scope="col">Templ8</th>
<th scope="col">Whiskers</th>
<th scope="col">micro-template</th>
</tr>
</thead>
<tbody>
Expand All @@ -75,6 +77,7 @@ <h2>Feature Comparisons</h2>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
<td><span class="no">✖</span></td>
</tr>
<tr>
<th scope="row">Browser Support</th>
Expand All @@ -88,6 +91,7 @@ <h2>Feature Comparisons</h2>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
</tr>
<tr>
<th scope="row">Available via npm</th>
Expand All @@ -101,6 +105,7 @@ <h2>Feature Comparisons</h2>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
</tr>
<tr>
<th scope="row">Variable Filters</th>
Expand All @@ -114,6 +119,7 @@ <h2>Feature Comparisons</h2>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
<td><span class="no">✖</span></td>
<td><span class="yes">✔</span></td>
</tr>
<tr>
<th scope="row">Shorthand HTML Syntax</th>
Expand All @@ -127,6 +133,7 @@ <h2>Feature Comparisons</h2>
<td><span class="no">✖</span></td>
<td><span class="no">✖</span></td>
<td><span class="no">✖</span></td>
<td><span class="no">✖</span></td>
</tr>
<li>
<th scope="row">Extends / Block Template Inheritance</th>
Expand All @@ -140,6 +147,7 @@ <h2>Feature Comparisons</h2>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
<td><span class="no">✖</span></td>
<td><span class="no">✖</span></td>
</li>
<tr>
<th scope="row">Escapes Output</th>
Expand All @@ -153,6 +161,7 @@ <h2>Feature Comparisons</h2>
<td><span class="yes">✔</span></td>
<td><span class="no">✖</span></td>
<td><span class="no">✖</span></td>
<td><span class="yes">✔</span></td>
</tr>
<tr>
<th scope="row">Iteration</th>
Expand All @@ -166,6 +175,7 @@ <h2>Feature Comparisons</h2>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
</tr>
<tr>
<th scope="row"><code>if/else</code> Conditionals</th>
Expand All @@ -179,6 +189,7 @@ <h2>Feature Comparisons</h2>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
</tr>
<tr>
<th scope="row"><code>else if</code> Conditionals</th>
Expand All @@ -192,6 +203,7 @@ <h2>Feature Comparisons</h2>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
<td><span class="no">✖</span></td>
<td><span class="yes">✔</span></td>
</tr>
<tr>
<th scope="row">Extendable Tags, Logic, and/or Filters</th>
Expand All @@ -205,6 +217,7 @@ <h2>Feature Comparisons</h2>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
<td><span class="no">✖</span></td>
<td><span class="no">✖</span></td>
</tr>
<tr>
<th scope="row">Partials / Includes<sup><a class="partial" href="#partials">✜</a></sup></th>
Expand All @@ -218,6 +231,7 @@ <h2>Feature Comparisons</h2>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
<td><span class="yes">✔</span></td>
</tr>
</tbody>
<tfoot>
Expand Down
26 changes: 26 additions & 0 deletions lib/languages/micro-template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
var template = require('micro-template').template,
fs = require('fs'),
data = {
header: 'Colors',
items: [
{name: 'red', current: true, url: '#Red'},
{name: 'green', current: false, url: '#Green'},
{name: 'blue', current: false, url: '#Blue'}
]
},
files = {
simple: fs.readFileSync(__dirname + '/../templates/micro-template/simple.html', 'utf8')
},
tpl = {};

template.variable = "tmpl";

exports.compile = function (type, callback) {
tpl[type] = template(files[type]);
callback();
};

exports.render = function (type, callback) {
tpl[type](data);
callback();
};
16 changes: 16 additions & 0 deletions lib/templates/micro-template/simple.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<h1><%= tmpl.header %></h1>
<% if (tmpl.items.length) { %>
<ul>
<% for (var i = 0, item; (item = tmpl.items[i]); i++) { %>
<% if (item.current) { %>
<li><strong><%= item.name %></strong></li>
<% } %>
<% if (!item.current) { %>
<li><a href="<%= item.url %>"><%= item.name %></a></li>
<% } %>
<% } %>
</ul>
<% } %>
<% if (tmpl.items.length == 0) { %>
<p>The list is empty.</p>
<% } %>
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"mu2": "0.5.3",
"swig": "0.7.0",
"Templ8": "0.2.1",
"whiskers": "0.1.0"
"whiskers": "0.1.0",
"micro-template": "0.1.0"
},
"main": "index",
"engines": {
Expand Down