Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add CommonJS package.json and test runner

  • Loading branch information...
commit 082e1b34022bf88794ab0dc194ba558849a19268 1 parent b1fa422
Tom Robinson authored
Showing with 30 additions and 0 deletions.
  1. +7 −0 package.json
  2. +23 −0 test/test-commonjs.js
View
7 package.json
@@ -0,0 +1,7 @@
+{
+ "name": "haml-js",
+ "description": "Haml ported to server-side Javascript. This is a traditional server-side templating language.",
+ "keywords": ["haml", "template"],
+ "author": "Tim Caswell",
+ "version": "0.0.1"
+}
View
23 test/test-commonjs.js
@@ -0,0 +1,23 @@
+var FILE = require("file");
+var ASSERT = require("assert");
+
+var Haml = require("../lib/haml");
+
+FILE.glob("test/*.haml").forEach(function(hamlFile) {
+ exports["test " + hamlFile] = function() {
+ var scopeFile = hamlFile.replace(/haml$/, "js");
+ var htmlFile = hamlFile.replace(/haml$/, "html");
+
+ var haml = FILE.read(hamlFile);
+ var expected = FILE.read(htmlFile);
+ var scope = FILE.exists(scopeFile) ? eval("("+FILE.read(scopeFile)+")") : {};
+
+ var js = Haml.compile(haml);
+ var js_opt = Haml.optimize(js);
+ var actual = Haml.execute(js_opt, scope.context, scope.locals);
+ ASSERT.eq(actual, expected);
+ }
+});
+
+if (module == require.main)
+ require("os").exit(require("test").run(exports));
Please sign in to comment.
Something went wrong with that request. Please try again.