Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't add in extra whitespace all over the place, it breaks things.

  • Loading branch information...
commit 8f603224b1a606ca1e87c8beed882022d06c093b 1 parent 83e34ff
Tim Caswell authored
20 lib/haml.js
View
@@ -328,8 +328,8 @@ if (typeof exports !== 'undefined') {
regexp: /^(\s*):(?:java)?script\s*$/,
process: function () {
return parse_interpol('\n<script type="text/javascript">\n' +
- '//<![CDATA[\n ' +
- this.contents.join("\n ") +
+ '//<![CDATA[\n' +
+ this.contents.join("\n") +
"\n//]]>\n</script>\n");
}
},
@@ -338,8 +338,8 @@ if (typeof exports !== 'undefined') {
{
regexp: /^(\s*):css\s*$/,
process: function () {
- return JSON.stringify('\n<style type="text/css">\n ' +
- this.contents.join("\n ") +
+ return JSON.stringify('\n<style type="text/css">\n' +
+ this.contents.join("\n") +
"\n</style>\n");
}
},
@@ -393,16 +393,16 @@ if (typeof exports !== 'undefined') {
output.push(function () {
// Escaped plain text
if (line[0] === '\\') {
- return JSON.stringify(line.substr(1, line.length) + "\n");
+ return JSON.stringify(line.substr(1, line.length));
}
// Plain variable data
if (line[0] === '=') {
line = line.substr(1, line.length).trim();
try {
- return JSON.stringify(JSON.parse(line) +"\n");
+ return JSON.stringify(JSON.parse(line));
} catch (e) {
- return line + ' +\n"\\n"';
+ return line;
}
}
@@ -410,14 +410,14 @@ if (typeof exports !== 'undefined') {
if (line.substr(0, 2) === "&=") {
line = line.substr(2, line.length).trim();
try {
- return JSON.stringify(html_escape(JSON.parse(line)) +"\n");
+ return JSON.stringify(html_escape(JSON.parse(line)));
} catch (e2) {
- return 'html_escape(' + line + ') +\n"\\n"';
+ return 'html_escape(' + line + ')';
}
}
// Plain text
- return JSON.stringify(line + "\n");
+ return JSON.stringify(line);
}());
}
2  package.json
View
@@ -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.1.2"
+ "version": "0.2.0"
}
5 test/div_nesting.html
View
@@ -1,4 +1 @@
-<div>Does not close properly
-<div>Nested same level as next div
-</div></div><div>Will be nested, but should be top level
-</div>
+<div>Does not close properly<div>Nested same level as next div</div></div><div>Will be nested, but should be top level</div>
2  test/embedded_code.html
View
@@ -1,7 +1,7 @@
<head>
<script type="text/javascript">
//<![CDATA[
- Page.chapter = {"name":"Ninja","page":42};
+Page.chapter = {"name":"Ninja","page":42};
//]]>
</script>
</head>
17 test/foreach.html
View
@@ -1,16 +1 @@
-<div style="color: #f80;" class="preview">My Rainbow
-</div><div style="color: #08f;" class="preview">My Rainbow
-</div><div style="color: #4f4;" class="preview">My Rainbow
-</div><dl><dt>name
-</dt><dd>Tim Caswell
-</dd><dt>age
-</dt><dd>27
-</dd></dl>1
-2
-3
-4
-5
-6
-7
-Hello
-World
+<div style="color: #f80;" class="preview">My Rainbow</div><div style="color: #08f;" class="preview">My Rainbow</div><div style="color: #4f4;" class="preview">My Rainbow</div><dl><dt>name</dt><dd>Tim Caswell</dd><dt>age</dt><dd>27</dd></dl>1234567HelloWorld
7 test/nested_context.html
View
@@ -1,6 +1 @@
-<p>Frank
-</p><div id="main"><div class="item">Frank: 1
-</div><div class="item">Frank: 2
-</div><div class="item">Frank: 3
-</div><div id="cool">Frank
-</div></div>
+<p>Frank</p><div id="main"><div class="item">Frank: 1</div><div class="item">Frank: 2</div><div class="item">Frank: 3</div><div id="cool">Frank</div></div>
5 test/no_self_close_div.haml
View
@@ -3,5 +3,6 @@
%div#a
%div I do not self close.
:javascript
- (function(){document.getElementById('a').textContent='I self
- close';})();
+ (function(){
+ document.getElementById('a').textContent='I self close';
+ })();
8 test/no_self_close_div.html
View
@@ -1,9 +1,9 @@
-<html><body><div id="a"></div><div>I do not self close.
-</div>
+<html><body><div id="a"></div><div>I do not self close.</div>
<script type="text/javascript">
//<![CDATA[
- (function(){document.getElementById('a').textContent='I self
- close';})();
+(function(){
+ document.getElementById('a').textContent='I self close';
+})();
//]]>
</script>
</body></html>
4 test/non-string-attribs.html
View
@@ -1,3 +1 @@
-<div id="plain">Plain Text
-</div><div id="escaped">&lt;escaped&gt;
-</div><input checked="checked" /><input /><input /><input /><input checked="0" /><input />
+<div id="plain">Plain Text</div><div id="escaped">&lt;escaped&gt;</div><input checked="checked" /><input /><input /><input /><input checked="0" /><input />
18 test/script_css.html
View
@@ -1,17 +1,15 @@
<head>
<script type="text/javascript">
//<![CDATA[
- function greet(message) {
- alert("Message from MCP: " + message);
- }
+function greet(message) {
+ alert("Message from MCP: " + message);
+}
//]]>
</script>
-<title>Script and Css test
-</title>
+<title>Script and Css test</title>
<style type="text/css">
- body {
- color: pink;
- }
+body {
+ color: pink;
+}
</style>
-</head><body onload="greet(&quot;I'm Pink&quot;)">COLOR ME PINK
-</body>
+</head><body onload="greet(&quot;I'm Pink&quot;)">COLOR ME PINK</body>
3  test/self_close.html
View
@@ -1,2 +1 @@
-<html><head><script></script><meta name="test" value="Monkey" /></head><body><a href="http://nodejs.org/">link
-</a></body></html>
+<html><head><script></script><meta name="test" value="Monkey" /></head><body><a href="http://nodejs.org/">link</a></body></html>
7 test/standard.html
View
@@ -1,8 +1,3 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Sample haml template
-</title></head><body><div class="profile"><div class="left column"><div id="date">January 1, 2009
-</div><div id="address">Richardson, TX
-</div></div><div class="right column"><div id="email">tim@creationix.com
-</div><div id="bio">Experienced software professional...
-</div></div></div></body></html>
+<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Sample haml template</title></head><body><div class="profile"><div class="left column"><div id="date">January 1, 2009</div><div id="address">Richardson, TX</div></div><div class="right column"><div id="email">tim@creationix.com</div><div id="bio">Experienced software professional...</div></div></div></body></html>
4 test/test.js
View
@@ -24,12 +24,14 @@ fs.readdir('.', function (err, files) {
sys.puts(haml_file + " Passed")
} catch (e) {
var message = e.name;
- if (e.message) message += ": " + e.message;
+ if (e.message) { message += ": " + e.message; }
+ sys.error(haml_file + " FAILED")
sys.error(message);
sys.error("\nJS:\n\n" + js);
sys.error("\nOptimized JS:\n\n" + js_opt);
sys.error("\nActual:\n\n" + actual);
sys.error("\nExpected:\n\n" + expected);
+ process.exit();
}
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.