From bde0ca543ab1f3f27e2e6e440781f276a7ea2590 Mon Sep 17 00:00:00 2001 From: Alexander Solovyov Date: Thu, 21 Jun 2012 15:32:06 +0300 Subject: [PATCH] eco templates --- index.html | 14 ++++++++++++++ lib/languages/eco.js | 24 ++++++++++++++++++++++++ lib/templates/eco/simple.html | 14 ++++++++++++++ package.json | 7 ++++--- 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 lib/languages/eco.js create mode 100644 lib/templates/eco/simple.html diff --git a/index.html b/index.html index 3094fe7..8fb9f3a 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.
  • +
  • Eco - Embedded CoffeeScript templates.
  • @@ -60,6 +61,7 @@

    Feature Comparisons

    Swig Templ8 Whiskers + Eco @@ -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/eco.js b/lib/languages/eco.js new file mode 100644 index 0000000..5e6b346 --- /dev/null +++ b/lib/languages/eco.js @@ -0,0 +1,24 @@ +var eco = require('eco'), + 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/eco/simple.html', 'utf8') + }, + tpl = {}; + +exports.compile = function (type, callback) { + tpl[type] = eco.compile(files[type]); + callback(); +}; + +exports.render = function (type, callback) { + tpl[type](data); + callback(); +}; diff --git a/lib/templates/eco/simple.html b/lib/templates/eco/simple.html new file mode 100644 index 0000000..d9bfc1f --- /dev/null +++ b/lib/templates/eco/simple.html @@ -0,0 +1,14 @@ +

    <%= header %>

    +<% if items.length: %> + +<% else %> +

    The list is empty.

    +<% end %> diff --git a/package.json b/package.json index 69c9008..5d33aa7 100644 --- a/package.json +++ b/package.json @@ -13,14 +13,15 @@ "underscore": ">=1.1.7", "coffeekup": "0.3.0", "ejs": "0.4.2", - "hamljs": "0.5.1", + "hamljs": "0.6.0", "haml": "0.4.2", - "jade": "0.16.0", + "jade": "0.26.1", "jqtpl": "1.0.6", "mu2": "0.5.3", "swig": "0.7.0", "Templ8": "0.2.1", - "whiskers": "0.1.0" + "whiskers": "0.1.0", + "eco": "1.1.0-rc-3" }, "main": "index", "engines": {