diff --git a/index.html b/index.html index 3094fe7..04fa14e 100644 --- a/index.html +++ b/index.html @@ -39,6 +39,7 @@

Template Languages (alphabetical)

  • Swig - Swig is a template engine inspired by the Django syntax.
  • Templ8 - JavaScript client/server template engine.
  • Whiskers - A mustachioed templating library.
  • +
  • micro-template - A template engine on JavaScript which like embed js.
  • @@ -60,6 +61,7 @@

    Feature Comparisons

    Swig Templ8 Whiskers + micro-template @@ -75,6 +77,7 @@

    Feature Comparisons

    + Browser Support @@ -88,6 +91,7 @@

    Feature Comparisons

    + Available via npm @@ -101,6 +105,7 @@

    Feature Comparisons

    + Variable Filters @@ -114,6 +119,7 @@

    Feature Comparisons

    + Shorthand HTML Syntax @@ -127,6 +133,7 @@

    Feature Comparisons

    +
  • Extends / Block Template Inheritance @@ -140,6 +147,7 @@

    Feature Comparisons

    +
  • Escapes Output @@ -153,6 +161,7 @@

    Feature Comparisons

    + Iteration @@ -166,6 +175,7 @@

    Feature Comparisons

    + if/else Conditionals @@ -179,6 +189,7 @@

    Feature Comparisons

    + else if Conditionals @@ -192,6 +203,7 @@

    Feature Comparisons

    + Extendable Tags, Logic, and/or Filters @@ -205,6 +217,7 @@

    Feature Comparisons

    + Partials / Includes @@ -218,6 +231,7 @@

    Feature Comparisons

    + diff --git a/lib/languages/micro-template.js b/lib/languages/micro-template.js new file mode 100644 index 0000000..7e13150 --- /dev/null +++ b/lib/languages/micro-template.js @@ -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(); +}; diff --git a/lib/templates/micro-template/simple.html b/lib/templates/micro-template/simple.html new file mode 100644 index 0000000..e5733dd --- /dev/null +++ b/lib/templates/micro-template/simple.html @@ -0,0 +1,16 @@ +

    <%= tmpl.header %>

    +<% if (tmpl.items.length) { %> + +<% } %> +<% if (tmpl.items.length == 0) { %> +

    The list is empty.

    +<% } %> diff --git a/package.json b/package.json index 69c9008..b53e6f3 100644 --- a/package.json +++ b/package.json @@ -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": {