Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

v0.2.1 Minor speed tweak

`Haml()` now caches the eval step so that there is no eval in executing a compiled template.  This should make things a bit faster.
  • Loading branch information...
commit e9d2b125024d3d53eaafa10e3d51fe416de85041 1 parent 8128768
@creationix authored
Showing with 15 additions and 11 deletions.
  1. +5 −1 CHANGELOG.markdown
  2. +9 −9 lib/haml.js
  3. +1 −1  package.json
View
6 CHANGELOG.markdown
@@ -1,6 +1,10 @@
# HAML-JS Changelog
-- **0.2.0** - *2010-03-31* - Function based API, Safe whitespace, Code interpolation.
+- **v0.2.1** - *2010-04-01* - Minor speed tweak
+
+ `Haml()` now caches the eval step so that there is no eval in executing a compiled template. This should make things a bit faster.
+
+- **v0.2.0** - *2010-03-31* - Function based API, Safe whitespace, Code interpolation.
At the request of some users, I've removed the new insertion into the generated html. This means that most html will be on one long line, but as an added advantage you won't have that extra whitespace next to your anchor labels messing up your visual display.
View
18 lib/haml.js
@@ -477,15 +477,15 @@ var Haml;
Haml = function (haml) {
var js = optimize(compile(haml));
- return function (locals) {
- with(locals || {}) {
- try {
- return eval("(" + js + ")");
- } catch (e) {
- return "\n<pre class='error'>" + html_escape(e.stack) + "</pre>\n";
- }
- }
- }
+ return new Function("locals",
+ html_escape + "\n" +
+ "with(locals || {}) {\n" +
+ " try {\n" +
+ " return (" + js + ");\n" +
+ " } catch (e) {\n" +
+ " return \"\\n<pre class='error'>\" + html_escape(e.stack) + \"</pre>\\n\";\n" +
+ " }\n" +
+ "}");
}
Haml.compile = compile;
Haml.optimize = optimize;
View
2  package.json
@@ -3,5 +3,5 @@
"description": "Haml ported to server-side Javascript. This is a traditional server-side templating language.",
"keywords": ["haml", "template", "nodejs"],
"author": "Tim Caswell",
- "version": "0.2.0"
+ "version": "0.2.1"
}
Please sign in to comment.
Something went wrong with that request. Please try again.