diff --git a/lib/haml.js b/lib/haml.js index c0c8f46..a51889c 100644 --- a/lib/haml.js +++ b/lib/haml.js @@ -806,7 +806,7 @@ JsCodeGenerator.prototype.appendEmbeddedCode = function(indentText, expression, escapeContents, perserveWhitespace, currentParsePoint) { this.outputBuffer.flush(); this.outputBuffer.appendToOutputBuffer(indentText + 'try {\n'); - this.outputBuffer.appendToOutputBuffer(indentText + ' var value = eval("' + expression.replace(/"/g, '\\"').replace(/\\n/g, '\\\\n') + '");\n'); + this.outputBuffer.appendToOutputBuffer(indentText + ' var value = eval("' + (_.str || _).trim(expression).replace(/"/g, '\\"').replace(/\\n/g, '\\\\n') + '");\n'); this.outputBuffer.appendToOutputBuffer(indentText + ' value = value === null ? "" : value;'); if (escapeContents) { this.outputBuffer.appendToOutputBuffer(indentText + ' html.push(haml.HamlRuntime.escapeHTML(String(value)));\n'); @@ -1062,7 +1062,7 @@ ProductionJsCodeGenerator.prototype.appendEmbeddedCode = function(indentText, expression, escapeContents, perserveWhitespace, currentParsePoint) { this.outputBuffer.flush(); - this.outputBuffer.appendToOutputBuffer(indentText + ' value = ' + expression + ';\n'); + this.outputBuffer.appendToOutputBuffer(indentText + ' value = ' + (_.str || _).trim(expression) + ';\n'); this.outputBuffer.appendToOutputBuffer(indentText + ' value = value === null ? "" : value;'); if (escapeContents) { return this.outputBuffer.appendToOutputBuffer(indentText + ' html.push(haml.HamlRuntime.escapeHTML(String(value)));\n'); diff --git a/lib/haml.min.js b/lib/haml.min.js index 83a174d..72cc72d 100644 --- a/lib/haml.min.js +++ b/lib/haml.min.js @@ -4,5 +4,5 @@ Copyright 2011-12, Ronald Holshausen (https://github.com/uglyog) Released under the MIT License (http://www.opensource.org/licenses/MIT) -*/(function(){var e,t,n,r,i,s,o,u,a,f={}.hasOwnProperty,l=function(e,t){function r(){this.constructor=e}for(var n in t)f.call(t,n)&&(e[n]=t[n]);return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e};a=this,r={escapeHTML:function(e){return String(e||"").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")},perserveWhitespace:function(e){var t,n,r,i;r=/<[a-zA-Z]+>[^<]*<\/[a-zA-Z]+>/g,n="",t=0,i=r.exec(e);if(i){while(i)n+=e.substring(t,i.index),n+=i[0].replace(/\n/g," "),t=i.index+i[0].length,i=r.exec(e);n+=e.substring(t)}else n=e;return n},templateError:function(e,t,n,r){var i,s;s=r+" at line "+e+" and character "+t+":\n"+n+"\n",i=0;while(i0&&n[0].length>0&&(c=this.combineAttributes(c,"class",n));if(i)for(l in i){if(!f.call(i,l))continue;c=this.combineAttributes(c,l,i[l])}if(r)try{g=r.call(e,e),g&&(y=null,g.id?y=g.id:g.get&&(y=g.get("id")),c=this.combineAttributes(c,"id",y),h=null,g["class"]?h=g["class"]:g.get&&(h=g.get("class")),c=this.combineAttributes(c,"class",h))}catch(b){throw haml.HamlRuntime.templateError(o,u,a,"Error evaluating object reference - "+b)}if(s)try{v=s.call(e,e);if(v)for(l in v){if(!f.call(v,l))continue;if(l==="data"){d=v[l];for(p in d){if(!f.call(d,p))continue;c=this.combineAttributes(c,"data-"+p,d[p])}}else c=this.combineAttributes(c,l,v[l])}}catch(w){throw haml.HamlRuntime.templateError(o,u,a,"Error evaluating attribute hash - "+w)}m="";if(c)for(l in c){if(!f.call(c,l))continue;haml.hasValue(c[l])&&((l==="id"||l==="for")&&c[l]instanceof Array?m+=" "+l+'="'+_(c[l]).flatten().join("-")+'"':l==="class"&&c[l]instanceof Array?m+=" "+l+'="'+_(c[l]).flatten().join(" ")+'"':m+=" "+l+'="'+haml.attrValue(l,c[l])+'"')}return m},indentText:function(e){var t,n;n="",t=0;while(t0?e&&e.id instanceof Array?e.id.unshift(n):e&&e.id?e.id=[e.id,n]:e?e.id=n:e={id:n}:t==="for"&&n.toString().length>0?e&&e["for"]instanceof Array?e["for"].unshift(n):e&&e["for"]?e["for"]=[e["for"],n]:e?e["for"]=n:e={"for":n}:t==="class"?(r=[],n instanceof Array?r=r.concat(n):r.push(n),e&&e["class"]?e["class"]=e["class"].concat(r):e?e["class"]=r:e={"class":r}):t!=="id"&&(e||(e={}),e[t]=n)),e}},o=function(){function e(e){var t,n,r,i=this;this.buffer=null,this.bufferIndex=null,this.prevToken=null,this.token=null;if(e.templateId!=null){r=document.getElementById(e.templateId);if(!r)throw"Did not find a template with ID '"+e.templateId+"'";this.buffer=r.text,this.bufferIndex=0}else e.template!=null?(this.buffer=e.template,this.bufferIndex=0):e.templateUrl!=null&&(t=function(t,n,r){throw"Failed to fetch haml template at URL "+e.templateUrl+": "+n+" "+r},n=function(e){return i.buffer=e,i.bufferIndex=0},jQuery.ajax({url:e.templateUrl,success:n,error:t,dataType:"text",async:!1,beforeSend:function(e){return e.withCredentials=!0}}))}return e.prototype.currentLineMatcher=/[^\n]*/g,e.prototype.tokenMatchers={whitespace:/[ \t]+/g,element:/%[a-zA-Z][a-zA-Z0-9]*/g,idSelector:/#[a-zA-Z_\-][a-zA-Z0-9_\-]*/g,classSelector:/\.[a-zA-Z0-9_\-]+/g,identifier:/[a-zA-Z][a-zA-Z0-9\-]*/g,quotedString:/[\'][^\'\n]*[\']/g,quotedString2:/[\"][^\"\n]*[\"]/g,comment:/\-#/g,escapeHtml:/\&=/g,unescapeHtml:/\!=/g,objectReference:/\[[a-zA-Z_@][a-zA-Z0-9_]*\]/g,doctype:/!!!/g,continueLine:/\|\s*\n/g,filter:/:\w+/g},e.prototype.matchToken=function(e){var t;e.lastIndex=this.bufferIndex,t=e.exec(this.buffer);if((t!=null?t.index:void 0)===this.bufferIndex)return t[0]},e.prototype.matchMultiCharToken=function(e,t,n){var r,i;if(!this.token){r=this.matchToken(e);if(r)return this.token=t,this.token.tokenString=(i=typeof n==="function"?n(r):void 0)!=null?i:r,this.token.matched=r,this.advanceCharsInBuffer(r.length)}},e.prototype.matchSingleCharToken=function(e,t){if(!this.token&&this.buffer.charAt(this.bufferIndex)===e)return this.token=t,this.token.tokenString=e,this.token.matched=e,this.advanceCharsInBuffer(1)},e.prototype.getNextToken=function(){var e,t,n,r,i,s,o;if(isNaN(this.bufferIndex))throw haml.HamlRuntime.templateError(this.lineNumber,this.characterNumber,this.currentLine,"An internal parser error has occurred in the HAML parser");this.prevToken=this.token,this.token=null;if(this.buffer===null||this.buffer.length===this.bufferIndex)this.token={eof:!0,token:"EOF"};else{this.initLine();if(!this.token){t=this.buffer.charCodeAt(this.bufferIndex),n=this.buffer.charCodeAt(this.bufferIndex+1);if(t===10||t===13&&n===10)this.token={eol:!0,token:"EOL"},t===13&&n===10?(this.advanceCharsInBuffer(2),this.token.matched=String.fromCharCode(t)+String.fromCharCode(n)):(this.advanceCharsInBuffer(1),this.token.matched=String.fromCharCode(t)),this.characterNumber=0,this.currentLine=this.getCurrentLine()}this.matchMultiCharToken(this.tokenMatchers.whitespace,{ws:!0,token:"WS"}),this.matchMultiCharToken(this.tokenMatchers.continueLine,{continueLine:!0,token:"CONTINUELINE"}),this.matchMultiCharToken(this.tokenMatchers.element,{element:!0,token:"ELEMENT"},function(e){return e.substring(1)}),this.matchMultiCharToken(this.tokenMatchers.idSelector,{idSelector:!0,token:"ID"},function(e){return e.substring(1)}),this.matchMultiCharToken(this.tokenMatchers.classSelector,{classSelector:!0,token:"CLASS"},function(e){return e.substring(1)}),this.matchMultiCharToken(this.tokenMatchers.identifier,{identifier:!0,token:"IDENTIFIER"}),this.matchMultiCharToken(this.tokenMatchers.doctype,{doctype:!0,token:"DOCTYPE"}),this.matchMultiCharToken(this.tokenMatchers.filter,{filter:!0,token:"FILTER"},function(e){return e.substring(1)}),this.token||(o=this.matchToken(this.tokenMatchers.quotedString),o||(o=this.matchToken(this.tokenMatchers.quotedString2)),o&&(this.token={string:!0,token:"STRING",tokenString:o.substring(1,o.length-1),matched:o},this.advanceCharsInBuffer(o.length))),this.matchMultiCharToken(this.tokenMatchers.comment,{comment:!0,token:"COMMENT"}),this.matchMultiCharToken(this.tokenMatchers.escapeHtml,{escapeHtml:!0,token:"ESCAPEHTML"}),this.matchMultiCharToken(this.tokenMatchers.unescapeHtml,{unescapeHtml:!0,token:"UNESCAPEHTML"}),this.matchMultiCharToken(this.tokenMatchers.objectReference,{objectReference:!0,token:"OBJECTREFERENCE"},function(e){return e.substring(1,e.length-1)});if(!this.token&&this.buffer&&this.buffer.charAt(this.bufferIndex)==="{"){i=this.bufferIndex+1,r=this.characterNumber,s=this.lineNumber,e=1;while(i1||this.buffer.charAt(i)!=="}"))this.buffer.charAt(i)==="{"?e++:this.buffer.charAt(i)==="}"&&e--,i++;if(i===this.buffer.length)throw this.characterNumber=r+1,this.lineNumber=s,this.parseError('Error parsing attribute hash - Did not find a terminating "}"');this.token={attributeHash:!0,token:"ATTRHASH",tokenString:this.buffer.substring(this.bufferIndex,i+1),matched:this.buffer.substring(this.bufferIndex,i+1)},this.advanceCharsInBuffer(i-this.bufferIndex+1)}this.matchSingleCharToken("(",{openBracket:!0,token:"OPENBRACKET"}),this.matchSingleCharToken(")",{closeBracket:!0,token:"CLOSEBRACKET"}),this.matchSingleCharToken("=",{equal:!0,token:"EQUAL"}),this.matchSingleCharToken("/",{slash:!0,token:"SLASH"}),this.matchSingleCharToken("!",{exclamation:!0,token:"EXCLAMATION"}),this.matchSingleCharToken("-",{minus:!0,token:"MINUS"}),this.matchSingleCharToken("&",{amp:!0,token:"AMP"}),this.matchSingleCharToken("<",{lt:!0,token:"LT"}),this.matchSingleCharToken(">",{gt:!0,token:"GT"}),this.matchSingleCharToken("~",{tilde:!0,token:"TILDE"}),this.token===null&&(this.token={unknown:!0,token:"UNKNOWN"})}return this.token},e.prototype.lookAhead=function(e){var t,n,r,i,s,o,u,a;a=null;if(e>0){i=this.token,u=this.prevToken,r=this.currentLine,o=this.lineNumber,n=this.characterNumber,t=this.bufferIndex,s=0;while(s++0)return this.buffer+=e},e.prototype.appendToOutputBuffer=function(e){if(e&&e.length>0)return this.flush(),this.outputBuffer+=e},e.prototype.flush=function(){return this.buffer&&this.buffer.length>0&&(this.outputBuffer+=this.generator.generateFlush(this.buffer)),this.buffer=""},e.prototype.output=function(){return this.outputBuffer},e.prototype.trimWhitespace=function(){var e,t;if(this.buffer.length>0){t=this.buffer.length-1;while(t>0){e=this.buffer.charAt(t);if(e===" "||e===" "||e==="\n")t--;else{if(!(t>1)||e!=="n"&&e!=="t"||this.buffer.charAt(t-1)!=="\\")break;t-=2}}if(t>0&&t0&&(r=this.replaceReservedWordsInHash(r),this.outputBuffer.appendToOutputBuffer(' hashFunction = function () { return eval("hashObject = '+r.replace(/"/g,'\\"').replace(/\n/g,"\\n")+'"); };\n')),i.length>0&&this.outputBuffer.appendToOutputBuffer(' objRefFn = function () { return eval("objRef = '+i.replace(/"/g,'\\"')+'"); };\n'),this.outputBuffer.appendToOutputBuffer(' html.push(haml.HamlRuntime.generateElementAttributes(context, "'+e+'", ["'+t.join('","')+'"], objRefFn, '+JSON.stringify(n)+", hashFunction, "+s.lineNumber+", "+s.characterNumber+', "'+this.escapeCode(s.currentLine)+'"));\n')},t.prototype.replaceReservedWordsInHash=function(e){var t,n,r,i,s;n=e,s=["class","for"];for(r=0,i=s.length;r0&&(s=e.charAt(u.index-1)),u.index>1&&(o=e.charAt(u.index-2)),s==="\\"&&o!=="\\"?(u.index!==0&&this.outputBuffer.append(this.processText(e.substring(i,u.index-1),n)),this.outputBuffer.append(this.processText(u[0]),n)):(this.outputBuffer.append(this.processText(e.substring(i,u.index)),n),this.appendEmbeddedCode(r.indentText(this.indent+1),u[1],n.escapeHTML,n.perserveWhitespace,t)),i=this.embeddedCodeBlockMatcher.lastIndex,u=this.embeddedCodeBlockMatcher.exec(e);if(i0&&(r=this.replaceReservedWordsInHash(r),this.outputBuffer.appendToOutputBuffer(" hashFunction = function () { return "+r+"; };\n")),i.length>0&&this.outputBuffer.appendToOutputBuffer(" objRefFn = function () { return "+i+"; };\n"),this.outputBuffer.appendToOutputBuffer(' html.push(haml.HamlRuntime.generateElementAttributes(context, "'+e+'", ["'+t.join('","')+'"], objRefFn, '+JSON.stringify(n)+", hashFunction, "+s.lineNumber+", "+s.characterNumber+', "'+this.escapeCode(s.currentLine)+'"));\n')},t.prototype.initOutput=function(){return this.outputBuffer.appendToOutputBuffer(" var html = [];\n var hashFunction = null, hashObject = null, objRef = null, objRefFn = null, value= null;\n with (context || {}) {\n")},t}(i),n=function(e){function t(){this.outputBuffer=new haml.Buffer(this)}return l(t,e),t.prototype.appendEmbeddedCode=function(e,t,n,r,i){var s;return this.outputBuffer.flush(),s=this.calcCodeIndent(),this.outputBuffer.appendToOutputBuffer(s+"try\n"),this.outputBuffer.appendToOutputBuffer(s+" exp = CoffeeScript.compile('"+t.replace(/'/g,"\\'").replace(/\\n/g,"\\\\n")+"', bare: true)\n"),this.outputBuffer.appendToOutputBuffer(s+" value = eval(exp)\n"),this.outputBuffer.appendToOutputBuffer(s+" value ?= ''\n"),n?this.outputBuffer.appendToOutputBuffer(s+" html.push(haml.HamlRuntime.escapeHTML(String(value)))\n"):r?this.outputBuffer.appendToOutputBuffer(s+" html.push(haml.HamlRuntime.perserveWhitespace(String(value)))\n"):this.outputBuffer.appendToOutputBuffer(s+" html.push(String(value))\n"),this.outputBuffer.appendToOutputBuffer(s+"catch e \n"),this.outputBuffer.appendToOutputBuffer(s+" throw new Error(haml.HamlRuntime.templateError("+i.lineNumber+", "+i.characterNumber+", '"+this.escapeCode(i.currentLine)+"',\n"),this.outputBuffer.appendToOutputBuffer(s+" 'Error evaluating expression - ' + e))\n")},t.prototype.initOutput=function(){return this.outputBuffer.appendToOutputBuffer("html = []\n")},t.prototype.closeAndReturnOutput=function(){return this.outputBuffer.flush(),this.outputBuffer.output()+'return html.join("")\n'},t.prototype.appendCodeLine=function(e,t){return this.outputBuffer.flush(),this.outputBuffer.appendToOutputBuffer(this.calcCodeIndent()),this.outputBuffer.appendToOutputBuffer((_.str||_).trim(e)),this.outputBuffer.appendToOutputBuffer(t),this.prevCodeIndent=this.indent},t.prototype.lineMatchesStartFunctionBlock=function(e){return e.match(/\) [\-=]>\s*$/)},t.prototype.lineMatchesStartBlock=function(e){return!0},t.prototype.closeOffCodeBlock=function(e){return this.outputBuffer.flush()},t.prototype.closeOffFunctionBlock=function(e){return this.outputBuffer.flush()},t.prototype.generateCodeForDynamicAttributes=function(e,t,n,r,i,s){var o;return this.outputBuffer.flush(),o=this.calcCodeIndent(),r.length>0&&(r=this.replaceReservedWordsInHash(r),this.outputBuffer.appendToOutputBuffer(o+"hashFunction = () -> s = CoffeeScript.compile('"+r.replace(/'/g,"\\'").replace(/\n/g,"\\n")+"', bare: true); eval 'hashObject = ' + s\n")),i.length>0&&this.outputBuffer.appendToOutputBuffer(o+"objRefFn = () -> s = CoffeeScript.compile('"+i.replace(/'/g,"\\'")+"', bare: true); eval 'objRef = ' + s\n"),this.outputBuffer.appendToOutputBuffer(o+"html.push(haml.HamlRuntime.generateElementAttributes(this, '"+e+"', ['"+t.join("','")+"'], objRefFn ? null, "+JSON.stringify(n)+", hashFunction ? null, "+s.lineNumber+", "+s.characterNumber+", '"+this.escapeCode(s.currentLine)+"'))\n")},t.prototype.replaceReservedWordsInHash=function(e){var t,n,r,i,s;n=e,s=["class","for"];for(r=0,i=s.length;r0&&(r=e.charAt(s.index-1)),s.index>1&&(i=e.charAt(s.index-2)),r==="\\"&&i!=="\\"?(s.index!==0&&(n+=this._escapeText(e.substring(t,s.index-1))),n+=this._escapeText("\\"+s[0])):(n+=this._escapeText(e.substring(t,s.index)),n+=s[0]),t=this.embeddedCodeBlockMatcher.lastIndex,s=this.embeddedCodeBlockMatcher.exec(e);return t=i;t=0<=i?++n:--n)if(((s=this.elementStack[t])!=null?s.block:void 0)||((o=this.elementStack[t])!=null?o.fnBlock:void 0))e+=1;return r.indentText(e)},t.prototype.appendTextContents=function(e,t,n,r){var i,s;if(t&&e.match(/#{[^}]*}/)){this.outputBuffer.flush(),i=s="";if(r!=null?r.escapeHTML:void 0)i="haml.HamlRuntime.escapeHTML(",s=")";else if(r!=null?r.perserveWhitespace:void 0)i="haml.HamlRuntime.perserveWhitespace(",s=")";return this.outputBuffer.appendToOutputBuffer(this.calcCodeIndent()+"html.push("+i+'"'+this.escapeCode(e)+'"'+s+")\n")}if(r!=null?r.escapeHTML:void 0)e=haml.HamlRuntime.escapeHTML(e);if(r!=null?r.perserveWhitespace:void 0)e=haml.HamlRuntime.perserveWhitespace(e);return this.outputBuffer.append(e)},t}(t),u={plain:function(e,t,n,r){var i,s,o;for(s=0,o=e.length;s\n'),t.outputBuffer.append(n+"//\n"),t.outputBuffer.append(n+"\n")},css:function(e,t,n,r){var i,s,o;t.outputBuffer.append(n+'\n")},cdata:function(e,t,n,r){var i,s,o;t.outputBuffer.append(n+"\n")},preserve:function(e,t,n,r){return t.appendTextContents(e.join("\n")+"\n",!0,r,{perserveWhitespace:!0})},escape:function(e,t,n,r){var i,s,o;for(s=0,o=e.length;s0){s=i.split(/\s+/);switch(s[0]){case"XML":s.length>1?n.outputBuffer.append(""):n.outputBuffer.append("");break;case"Strict":n.outputBuffer.append('');break;case"Frameset":n.outputBuffer.append('');break;case"5":n.outputBuffer.append("");break;case"1.1":n.outputBuffer.append('');break;case"Basic":n.outputBuffer.append('');break;case"Mobile":n.outputBuffer.append('');break;case"RDFa":n.outputBuffer.append('')}}else n.outputBuffer.append('');return n.outputBuffer.append(this._newline(e)),e.getNextToken()}},_filter:function(e,t,n){var r,i,s,o;if(e.token.filter){r=e.token.tokenString;if(!haml.filters[r])throw e.parseError("Filter '"+r+"' not registered. Filter functions need to be added to 'haml.filters'.");e.skipToEOLorEOF(),e.getNextToken(),s=haml._whitespace(e),i=[];while(!e.token.eof&&s>t)o=e.skipToEOLorEOF(),i.push(haml.HamlRuntime.indentText(s-t-1)+o),e.getNextToken(),s=haml._whitespace(e);return haml.filters[r](i,n,haml.HamlRuntime.indentText(t),e.currentParsePoint()),e.pushBackToken()}},_commentLine:function(e,t,n,i){var s,o;if(e.token.comment){e.skipToEOLorEOF(),e.getNextToken(),o=this._whitespace(e);while(!e.token.eof&&o>t)e.skipToEOLorEOF(),e.getNextToken(),o=this._whitespace(e);if(o>0)return e.pushBackToken()}else if(e.token.slash)return haml._closeElements(t,n,e,i),i.outputBuffer.append(r.indentText(t)),i.outputBuffer.append(""+t[e].eol):t[e].htmlConditionalComment?i.outputBuffer.append(r.indentText(e)+""+t[e].eol):t[e].block?i.closeOffCodeBlock(n):t[e].fnBlock?i.closeOffFunctionBlock(n):(s=!t[e].tagOptions||t[e].tagOptions.innerWhitespace,s?i.outputBuffer.append(r.indentText(e)):i.outputBuffer.trimWhitespace(),i.outputBuffer.append(""),o=!t[e].tagOptions|| +*/(function(){var e,t,n,r,i,s,o,u,a,f={}.hasOwnProperty,l=function(e,t){function r(){this.constructor=e}for(var n in t)f.call(t,n)&&(e[n]=t[n]);return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e};a=this,r={escapeHTML:function(e){return String(e||"").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")},perserveWhitespace:function(e){var t,n,r,i;r=/<[a-zA-Z]+>[^<]*<\/[a-zA-Z]+>/g,n="",t=0,i=r.exec(e);if(i){while(i)n+=e.substring(t,i.index),n+=i[0].replace(/\n/g," "),t=i.index+i[0].length,i=r.exec(e);n+=e.substring(t)}else n=e;return n},templateError:function(e,t,n,r){var i,s;s=r+" at line "+e+" and character "+t+":\n"+n+"\n",i=0;while(i0&&n[0].length>0&&(c=this.combineAttributes(c,"class",n));if(i)for(l in i){if(!f.call(i,l))continue;c=this.combineAttributes(c,l,i[l])}if(r)try{g=r.call(e,e),g&&(y=null,g.id?y=g.id:g.get&&(y=g.get("id")),c=this.combineAttributes(c,"id",y),h=null,g["class"]?h=g["class"]:g.get&&(h=g.get("class")),c=this.combineAttributes(c,"class",h))}catch(b){throw haml.HamlRuntime.templateError(o,u,a,"Error evaluating object reference - "+b)}if(s)try{v=s.call(e,e);if(v)for(l in v){if(!f.call(v,l))continue;if(l==="data"){d=v[l];for(p in d){if(!f.call(d,p))continue;c=this.combineAttributes(c,"data-"+p,d[p])}}else c=this.combineAttributes(c,l,v[l])}}catch(w){throw haml.HamlRuntime.templateError(o,u,a,"Error evaluating attribute hash - "+w)}m="";if(c)for(l in c){if(!f.call(c,l))continue;haml.hasValue(c[l])&&((l==="id"||l==="for")&&c[l]instanceof Array?m+=" "+l+'="'+_(c[l]).flatten().join("-")+'"':l==="class"&&c[l]instanceof Array?m+=" "+l+'="'+_(c[l]).flatten().join(" ")+'"':m+=" "+l+'="'+haml.attrValue(l,c[l])+'"')}return m},indentText:function(e){var t,n;n="",t=0;while(t0?e&&e.id instanceof Array?e.id.unshift(n):e&&e.id?e.id=[e.id,n]:e?e.id=n:e={id:n}:t==="for"&&n.toString().length>0?e&&e["for"]instanceof Array?e["for"].unshift(n):e&&e["for"]?e["for"]=[e["for"],n]:e?e["for"]=n:e={"for":n}:t==="class"?(r=[],n instanceof Array?r=r.concat(n):r.push(n),e&&e["class"]?e["class"]=e["class"].concat(r):e?e["class"]=r:e={"class":r}):t!=="id"&&(e||(e={}),e[t]=n)),e}},o=function(){function e(e){var t,n,r,i=this;this.buffer=null,this.bufferIndex=null,this.prevToken=null,this.token=null;if(e.templateId!=null){r=document.getElementById(e.templateId);if(!r)throw"Did not find a template with ID '"+e.templateId+"'";this.buffer=r.text,this.bufferIndex=0}else e.template!=null?(this.buffer=e.template,this.bufferIndex=0):e.templateUrl!=null&&(t=function(t,n,r){throw"Failed to fetch haml template at URL "+e.templateUrl+": "+n+" "+r},n=function(e){return i.buffer=e,i.bufferIndex=0},jQuery.ajax({url:e.templateUrl,success:n,error:t,dataType:"text",async:!1,beforeSend:function(e){return e.withCredentials=!0}}))}return e.prototype.currentLineMatcher=/[^\n]*/g,e.prototype.tokenMatchers={whitespace:/[ \t]+/g,element:/%[a-zA-Z][a-zA-Z0-9]*/g,idSelector:/#[a-zA-Z_\-][a-zA-Z0-9_\-]*/g,classSelector:/\.[a-zA-Z0-9_\-]+/g,identifier:/[a-zA-Z][a-zA-Z0-9\-]*/g,quotedString:/[\'][^\'\n]*[\']/g,quotedString2:/[\"][^\"\n]*[\"]/g,comment:/\-#/g,escapeHtml:/\&=/g,unescapeHtml:/\!=/g,objectReference:/\[[a-zA-Z_@][a-zA-Z0-9_]*\]/g,doctype:/!!!/g,continueLine:/\|\s*\n/g,filter:/:\w+/g},e.prototype.matchToken=function(e){var t;e.lastIndex=this.bufferIndex,t=e.exec(this.buffer);if((t!=null?t.index:void 0)===this.bufferIndex)return t[0]},e.prototype.matchMultiCharToken=function(e,t,n){var r,i;if(!this.token){r=this.matchToken(e);if(r)return this.token=t,this.token.tokenString=(i=typeof n==="function"?n(r):void 0)!=null?i:r,this.token.matched=r,this.advanceCharsInBuffer(r.length)}},e.prototype.matchSingleCharToken=function(e,t){if(!this.token&&this.buffer.charAt(this.bufferIndex)===e)return this.token=t,this.token.tokenString=e,this.token.matched=e,this.advanceCharsInBuffer(1)},e.prototype.getNextToken=function(){var e,t,n,r,i,s,o;if(isNaN(this.bufferIndex))throw haml.HamlRuntime.templateError(this.lineNumber,this.characterNumber,this.currentLine,"An internal parser error has occurred in the HAML parser");this.prevToken=this.token,this.token=null;if(this.buffer===null||this.buffer.length===this.bufferIndex)this.token={eof:!0,token:"EOF"};else{this.initLine();if(!this.token){t=this.buffer.charCodeAt(this.bufferIndex),n=this.buffer.charCodeAt(this.bufferIndex+1);if(t===10||t===13&&n===10)this.token={eol:!0,token:"EOL"},t===13&&n===10?(this.advanceCharsInBuffer(2),this.token.matched=String.fromCharCode(t)+String.fromCharCode(n)):(this.advanceCharsInBuffer(1),this.token.matched=String.fromCharCode(t)),this.characterNumber=0,this.currentLine=this.getCurrentLine()}this.matchMultiCharToken(this.tokenMatchers.whitespace,{ws:!0,token:"WS"}),this.matchMultiCharToken(this.tokenMatchers.continueLine,{continueLine:!0,token:"CONTINUELINE"}),this.matchMultiCharToken(this.tokenMatchers.element,{element:!0,token:"ELEMENT"},function(e){return e.substring(1)}),this.matchMultiCharToken(this.tokenMatchers.idSelector,{idSelector:!0,token:"ID"},function(e){return e.substring(1)}),this.matchMultiCharToken(this.tokenMatchers.classSelector,{classSelector:!0,token:"CLASS"},function(e){return e.substring(1)}),this.matchMultiCharToken(this.tokenMatchers.identifier,{identifier:!0,token:"IDENTIFIER"}),this.matchMultiCharToken(this.tokenMatchers.doctype,{doctype:!0,token:"DOCTYPE"}),this.matchMultiCharToken(this.tokenMatchers.filter,{filter:!0,token:"FILTER"},function(e){return e.substring(1)}),this.token||(o=this.matchToken(this.tokenMatchers.quotedString),o||(o=this.matchToken(this.tokenMatchers.quotedString2)),o&&(this.token={string:!0,token:"STRING",tokenString:o.substring(1,o.length-1),matched:o},this.advanceCharsInBuffer(o.length))),this.matchMultiCharToken(this.tokenMatchers.comment,{comment:!0,token:"COMMENT"}),this.matchMultiCharToken(this.tokenMatchers.escapeHtml,{escapeHtml:!0,token:"ESCAPEHTML"}),this.matchMultiCharToken(this.tokenMatchers.unescapeHtml,{unescapeHtml:!0,token:"UNESCAPEHTML"}),this.matchMultiCharToken(this.tokenMatchers.objectReference,{objectReference:!0,token:"OBJECTREFERENCE"},function(e){return e.substring(1,e.length-1)});if(!this.token&&this.buffer&&this.buffer.charAt(this.bufferIndex)==="{"){i=this.bufferIndex+1,r=this.characterNumber,s=this.lineNumber,e=1;while(i1||this.buffer.charAt(i)!=="}"))this.buffer.charAt(i)==="{"?e++:this.buffer.charAt(i)==="}"&&e--,i++;if(i===this.buffer.length)throw this.characterNumber=r+1,this.lineNumber=s,this.parseError('Error parsing attribute hash - Did not find a terminating "}"');this.token={attributeHash:!0,token:"ATTRHASH",tokenString:this.buffer.substring(this.bufferIndex,i+1),matched:this.buffer.substring(this.bufferIndex,i+1)},this.advanceCharsInBuffer(i-this.bufferIndex+1)}this.matchSingleCharToken("(",{openBracket:!0,token:"OPENBRACKET"}),this.matchSingleCharToken(")",{closeBracket:!0,token:"CLOSEBRACKET"}),this.matchSingleCharToken("=",{equal:!0,token:"EQUAL"}),this.matchSingleCharToken("/",{slash:!0,token:"SLASH"}),this.matchSingleCharToken("!",{exclamation:!0,token:"EXCLAMATION"}),this.matchSingleCharToken("-",{minus:!0,token:"MINUS"}),this.matchSingleCharToken("&",{amp:!0,token:"AMP"}),this.matchSingleCharToken("<",{lt:!0,token:"LT"}),this.matchSingleCharToken(">",{gt:!0,token:"GT"}),this.matchSingleCharToken("~",{tilde:!0,token:"TILDE"}),this.token===null&&(this.token={unknown:!0,token:"UNKNOWN"})}return this.token},e.prototype.lookAhead=function(e){var t,n,r,i,s,o,u,a;a=null;if(e>0){i=this.token,u=this.prevToken,r=this.currentLine,o=this.lineNumber,n=this.characterNumber,t=this.bufferIndex,s=0;while(s++0)return this.buffer+=e},e.prototype.appendToOutputBuffer=function(e){if(e&&e.length>0)return this.flush(),this.outputBuffer+=e},e.prototype.flush=function(){return this.buffer&&this.buffer.length>0&&(this.outputBuffer+=this.generator.generateFlush(this.buffer)),this.buffer=""},e.prototype.output=function(){return this.outputBuffer},e.prototype.trimWhitespace=function(){var e,t;if(this.buffer.length>0){t=this.buffer.length-1;while(t>0){e=this.buffer.charAt(t);if(e===" "||e===" "||e==="\n")t--;else{if(!(t>1)||e!=="n"&&e!=="t"||this.buffer.charAt(t-1)!=="\\")break;t-=2}}if(t>0&&t0&&(r=this.replaceReservedWordsInHash(r),this.outputBuffer.appendToOutputBuffer(' hashFunction = function () { return eval("hashObject = '+r.replace(/"/g,'\\"').replace(/\n/g,"\\n")+'"); };\n')),i.length>0&&this.outputBuffer.appendToOutputBuffer(' objRefFn = function () { return eval("objRef = '+i.replace(/"/g,'\\"')+'"); };\n'),this.outputBuffer.appendToOutputBuffer(' html.push(haml.HamlRuntime.generateElementAttributes(context, "'+e+'", ["'+t.join('","')+'"], objRefFn, '+JSON.stringify(n)+", hashFunction, "+s.lineNumber+", "+s.characterNumber+', "'+this.escapeCode(s.currentLine)+'"));\n')},t.prototype.replaceReservedWordsInHash=function(e){var t,n,r,i,s;n=e,s=["class","for"];for(r=0,i=s.length;r0&&(s=e.charAt(u.index-1)),u.index>1&&(o=e.charAt(u.index-2)),s==="\\"&&o!=="\\"?(u.index!==0&&this.outputBuffer.append(this.processText(e.substring(i,u.index-1),n)),this.outputBuffer.append(this.processText(u[0]),n)):(this.outputBuffer.append(this.processText(e.substring(i,u.index)),n),this.appendEmbeddedCode(r.indentText(this.indent+1),u[1],n.escapeHTML,n.perserveWhitespace,t)),i=this.embeddedCodeBlockMatcher.lastIndex,u=this.embeddedCodeBlockMatcher.exec(e);if(i0&&(r=this.replaceReservedWordsInHash(r),this.outputBuffer.appendToOutputBuffer(" hashFunction = function () { return "+r+"; };\n")),i.length>0&&this.outputBuffer.appendToOutputBuffer(" objRefFn = function () { return "+i+"; };\n"),this.outputBuffer.appendToOutputBuffer(' html.push(haml.HamlRuntime.generateElementAttributes(context, "'+e+'", ["'+t.join('","')+'"], objRefFn, '+JSON.stringify(n)+", hashFunction, "+s.lineNumber+", "+s.characterNumber+', "'+this.escapeCode(s.currentLine)+'"));\n')},t.prototype.initOutput=function(){return this.outputBuffer.appendToOutputBuffer(" var html = [];\n var hashFunction = null, hashObject = null, objRef = null, objRefFn = null, value= null;\n with (context || {}) {\n")},t}(i),n=function(e){function t(){this.outputBuffer=new haml.Buffer(this)}return l(t,e),t.prototype.appendEmbeddedCode=function(e,t,n,r,i){var s;return this.outputBuffer.flush(),s=this.calcCodeIndent(),this.outputBuffer.appendToOutputBuffer(s+"try\n"),this.outputBuffer.appendToOutputBuffer(s+" exp = CoffeeScript.compile('"+t.replace(/'/g,"\\'").replace(/\\n/g,"\\\\n")+"', bare: true)\n"),this.outputBuffer.appendToOutputBuffer(s+" value = eval(exp)\n"),this.outputBuffer.appendToOutputBuffer(s+" value ?= ''\n"),n?this.outputBuffer.appendToOutputBuffer(s+" html.push(haml.HamlRuntime.escapeHTML(String(value)))\n"):r?this.outputBuffer.appendToOutputBuffer(s+" html.push(haml.HamlRuntime.perserveWhitespace(String(value)))\n"):this.outputBuffer.appendToOutputBuffer(s+" html.push(String(value))\n"),this.outputBuffer.appendToOutputBuffer(s+"catch e \n"),this.outputBuffer.appendToOutputBuffer(s+" throw new Error(haml.HamlRuntime.templateError("+i.lineNumber+", "+i.characterNumber+", '"+this.escapeCode(i.currentLine)+"',\n"),this.outputBuffer.appendToOutputBuffer(s+" 'Error evaluating expression - ' + e))\n")},t.prototype.initOutput=function(){return this.outputBuffer.appendToOutputBuffer("html = []\n")},t.prototype.closeAndReturnOutput=function(){return this.outputBuffer.flush(),this.outputBuffer.output()+'return html.join("")\n'},t.prototype.appendCodeLine=function(e,t){return this.outputBuffer.flush(),this.outputBuffer.appendToOutputBuffer(this.calcCodeIndent()),this.outputBuffer.appendToOutputBuffer((_.str||_).trim(e)),this.outputBuffer.appendToOutputBuffer(t),this.prevCodeIndent=this.indent},t.prototype.lineMatchesStartFunctionBlock=function(e){return e.match(/\) [\-=]>\s*$/)},t.prototype.lineMatchesStartBlock=function(e){return!0},t.prototype.closeOffCodeBlock=function(e){return this.outputBuffer.flush()},t.prototype.closeOffFunctionBlock=function(e){return this.outputBuffer.flush()},t.prototype.generateCodeForDynamicAttributes=function(e,t,n,r,i,s){var o;return this.outputBuffer.flush(),o=this.calcCodeIndent(),r.length>0&&(r=this.replaceReservedWordsInHash(r),this.outputBuffer.appendToOutputBuffer(o+"hashFunction = () -> s = CoffeeScript.compile('"+r.replace(/'/g,"\\'").replace(/\n/g,"\\n")+"', bare: true); eval 'hashObject = ' + s\n")),i.length>0&&this.outputBuffer.appendToOutputBuffer(o+"objRefFn = () -> s = CoffeeScript.compile('"+i.replace(/'/g,"\\'")+"', bare: true); eval 'objRef = ' + s\n"),this.outputBuffer.appendToOutputBuffer(o+"html.push(haml.HamlRuntime.generateElementAttributes(this, '"+e+"', ['"+t.join("','")+"'], objRefFn ? null, "+JSON.stringify(n)+", hashFunction ? null, "+s.lineNumber+", "+s.characterNumber+", '"+this.escapeCode(s.currentLine)+"'))\n")},t.prototype.replaceReservedWordsInHash=function(e){var t,n,r,i,s;n=e,s=["class","for"];for(r=0,i=s.length;r0&&(r=e.charAt(s.index-1)),s.index>1&&(i=e.charAt(s.index-2)),r==="\\"&&i!=="\\"?(s.index!==0&&(n+=this._escapeText(e.substring(t,s.index-1))),n+=this._escapeText("\\"+s[0])):(n+=this._escapeText(e.substring(t,s.index)),n+=s[0]),t=this.embeddedCodeBlockMatcher.lastIndex,s=this.embeddedCodeBlockMatcher.exec(e);return t=i;t=0<=i?++n:--n)if(((s=this.elementStack[t])!=null?s.block:void 0)||((o=this.elementStack[t])!=null?o.fnBlock:void 0))e+=1;return r.indentText(e)},t.prototype.appendTextContents=function(e,t,n,r){var i,s;if(t&&e.match(/#{[^}]*}/)){this.outputBuffer.flush(),i=s="";if(r!=null?r.escapeHTML:void 0)i="haml.HamlRuntime.escapeHTML(",s=")";else if(r!=null?r.perserveWhitespace:void 0)i="haml.HamlRuntime.perserveWhitespace(",s=")";return this.outputBuffer.appendToOutputBuffer(this.calcCodeIndent()+"html.push("+i+'"'+this.escapeCode(e)+'"'+s+")\n")}if(r!=null?r.escapeHTML:void 0)e=haml.HamlRuntime.escapeHTML(e);if(r!=null?r.perserveWhitespace:void 0)e=haml.HamlRuntime.perserveWhitespace(e);return this.outputBuffer.append(e)},t}(t),u={plain:function(e,t,n,r){var i,s,o;for(s=0,o=e.length;s\n'),t.outputBuffer.append(n+"//\n"),t.outputBuffer.append(n+"\n")},css:function(e,t,n,r){var i,s,o;t.outputBuffer.append(n+'\n")},cdata:function(e,t,n,r){var i,s,o;t.outputBuffer.append(n+"\n")},preserve:function(e,t,n,r){return t.appendTextContents(e.join("\n")+"\n",!0,r,{perserveWhitespace:!0})},escape:function(e,t,n,r){var i,s,o;for(s=0,o=e.length;s0){s=i.split(/\s+/);switch(s[0]){case"XML":s.length>1?n.outputBuffer.append(""):n.outputBuffer.append("");break;case"Strict":n.outputBuffer.append('');break;case"Frameset":n.outputBuffer.append('');break;case"5":n.outputBuffer.append("");break;case"1.1":n.outputBuffer.append('');break;case"Basic":n.outputBuffer.append('');break;case"Mobile":n.outputBuffer.append('');break;case"RDFa":n.outputBuffer.append('')}}else n.outputBuffer.append('');return n.outputBuffer.append(this._newline(e)),e.getNextToken()}},_filter:function(e,t,n){var r,i,s,o;if(e.token.filter){r=e.token.tokenString;if(!haml.filters[r])throw e.parseError("Filter '"+r+"' not registered. Filter functions need to be added to 'haml.filters'.");e.skipToEOLorEOF(),e.getNextToken(),s=haml._whitespace(e),i=[];while(!e.token.eof&&s>t)o=e.skipToEOLorEOF(),i.push(haml.HamlRuntime.indentText(s-t-1)+o),e.getNextToken(),s=haml._whitespace(e);return haml.filters[r](i,n,haml.HamlRuntime.indentText(t),e.currentParsePoint()),e.pushBackToken()}},_commentLine:function(e,t,n,i){var s,o;if(e.token.comment){e.skipToEOLorEOF(),e.getNextToken(),o=this._whitespace(e);while(!e.token.eof&&o>t)e.skipToEOLorEOF(),e.getNextToken(),o=this._whitespace(e);if(o>0)return e.pushBackToken()}else if(e.token.slash)return haml._closeElements(t,n,e,i),i.outputBuffer.append(r.indentText(t)),i.outputBuffer.append(""+t[e].eol):t[e].htmlConditionalComment?i.outputBuffer.append(r.indentText(e)+""+t[e].eol):t[e].block?i.closeOffCodeBlock(n):t[e].fnBlock?i.closeOffFunctionBlock(n):(s=!t[e].tagOptions||t[e].tagOptions.innerWhitespace,s?i.outputBuffer.append(r.indentText(e)):i.outputBuffer.trimWhitespace(),i.outputBuffer.append(""),o=!t[e].tagOptions|| t[e].tagOptions.outerWhitespace,haml._parentInnerWhitespace(t,e)&&o&&i.outputBuffer.append("\n")),t[e]=null,i.mark()},_closeElements:function(e,t,n,r){var i,s;i=t.length-1,s=[];while(i>=e)s.push(this._closeElement(i--,t,n,r));return s},_openElement:function(e,t,n,i,s,o,u,a,f,l,c){var h,p,d;h=n.length===0?"div":n,p=this._parentInnerWhitespace(f,t),d=!l||l.outerWhitespace,d||c.outputBuffer.trimWhitespace(),t>0&&p&&d&&c.outputBuffer.append(r.indentText(t)),c.outputBuffer.append("<"+h),a.length>0||o.length>0?c.generateCodeForDynamicAttributes(i,s,u,a,o,e):c.outputBuffer.append(r.generateElementAttributes(null,i,s,null,u,null,e.lineNumber,e.characterNumber,e.currentLine));if(l.selfClosingTag){c.outputBuffer.append("/>");if(l.outerWhitespace)return c.outputBuffer.append("\n")}else{c.outputBuffer.append(">"),f[t]={tag:h,tagOptions:l};if(l.innerWhitespace)return c.outputBuffer.append("\n")}},_isSelfClosingTag:function(e){return e==="meta"||e==="img"||e==="link"||e==="script"||e==="br"||e==="hr"},_tagHasContents:function(e,t){var n;return t.isEolOrEof()?(n=t.lookAhead(1),n.ws&&n.tokenString.length/2>e):!0},_parentInnerWhitespace:function(e,t){return t===0||!e[t-1]||!e[t-1].tagOptions||e[t-1].tagOptions.innerWhitespace},_lineHasElement:function(e,t,n){return e.length>0||t.length>0||n.length>0},hasValue:function(e){return e!=null&&e!==!1},attrValue:function(e,t){return e==="selected"||e==="checked"||e==="disabled"?e:t},_whitespace:function(e){var t,n,r;n=0;if(e.token.ws){t=0,r=e.token.tokenString;while(t '
\n' + ' \n' + '
\n') - + describe 'Issue 13 - comments', () -> beforeEach () -> @@ -107,7 +107,7 @@ describe 'haml issues', () -> '
\n' + ' You should see me\n' + '
\n') - + describe 'Issue #21 - text node followed by tag node fails', () -> hex = (str) -> @@ -246,8 +246,8 @@ describe 'haml issues', () -> ''' options = [ - {value: '1', text: 'text 1'}, - {value: '2', text: 'text 2'}, + {value: '1', text: 'text 1'}, + {value: '2', text: 'text 2'}, {value: '3', text: 'text 3'} ] expect(_(haml.compileHaml(source: hamlSource, generator: 'coffeescript').call(options: options, selected: '1')).trim()).toEqual(expected) @@ -278,8 +278,8 @@ describe 'haml issues', () -> ''' options = [ - {value: '1', text: 'text 1'}, - {value: '2', text: 'text 2'}, + {value: '1', text: 'text 1'}, + {value: '2', text: 'text 2'}, {value: '3', text: 'text 3'} ] expect(_(haml.compileHaml(source: hamlSource, generator: 'coffeescript').call(options: options, selected: '1')).trim()).toEqual(expected) @@ -299,4 +299,32 @@ describe 'haml issues', () -> © Company 2012

''' - expect(_(haml.compileHaml(source: hamlSource)()).trim()).toEqual(expected) \ No newline at end of file + expect(_(haml.compileHaml(source: hamlSource)()).trim()).toEqual(expected) + + describe 'Issue #31 - new line in eval breaking generated function', () -> + + it 'should not blow up', () -> + + hamlSource = + ''' + %div{class: 'hero-unit'} + %h2= email.subject + %iframe{class: 'email-preview', src: iframeSource} + ''' + expected = + ''' +
+

+ Issue #31 +

+ +
+ ''' + + data = { + email: {subject: 'Issue #31'}, + iframeSource: 'blahblahblah' + } + + expect(_(haml.compileHaml(source: hamlSource)(data)).trim()).toEqual(expected) diff --git a/src/jscodegenerator.coffee b/src/jscodegenerator.coffee index 4390fcf..826bf0d 100644 --- a/src/jscodegenerator.coffee +++ b/src/jscodegenerator.coffee @@ -14,7 +14,7 @@ class JsCodeGenerator extends CodeGenerator @outputBuffer.appendToOutputBuffer(indentText + 'try {\n') @outputBuffer.appendToOutputBuffer(indentText + ' var value = eval("' + - expression.replace(/"/g, '\\"').replace(/\\n/g, '\\\\n') + '");\n') + (_.str || _).trim(expression).replace(/"/g, '\\"').replace(/\\n/g, '\\\\n') + '");\n') @outputBuffer.appendToOutputBuffer(indentText + ' value = value === null ? "" : value;') if escapeContents @outputBuffer.appendToOutputBuffer(indentText + ' html.push(haml.HamlRuntime.escapeHTML(String(value)));\n') diff --git a/src/productionjscodegenerator.coffee b/src/productionjscodegenerator.coffee index 1af8cf2..b50010f 100644 --- a/src/productionjscodegenerator.coffee +++ b/src/productionjscodegenerator.coffee @@ -9,7 +9,7 @@ class ProductionJsCodeGenerator extends JsCodeGenerator appendEmbeddedCode: (indentText, expression, escapeContents, perserveWhitespace, currentParsePoint) -> @outputBuffer.flush() - @outputBuffer.appendToOutputBuffer(indentText + ' value = ' + expression + ';\n') + @outputBuffer.appendToOutputBuffer(indentText + ' value = ' + (_.str || _).trim(expression) + ';\n') @outputBuffer.appendToOutputBuffer(indentText + ' value = value === null ? "" : value;') if escapeContents @outputBuffer.appendToOutputBuffer(indentText + ' html.push(haml.HamlRuntime.escapeHTML(String(value)));\n') diff --git a/src/tokiniser.coffee b/src/tokiniser.coffee index 42530f2..357afa4 100644 --- a/src/tokiniser.coffee +++ b/src/tokiniser.coffee @@ -257,7 +257,6 @@ class Tokeniser text += contents.substring(0, contents.length - 1) @advanceCharsInBuffer(contents.length - 1) @getNextToken() - #@pushBackToken() text ###