Skip to content

Commit

Permalink
now can also use #{} interpolation to insert complicated expressions …
Browse files Browse the repository at this point in the history
…in a HTML-style attribute:

like to this:
input(name='name' class='widget_#{id}' value='text_#{value}")
  • Loading branch information
arden committed Feb 10, 2011
1 parent 2fd4f11 commit 8208868
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/compiler.js
Expand Up @@ -268,10 +268,13 @@ Compiler.prototype = {
classes = [];
if (this.terse) buf.push('terse: true');
attrs.forEach(function(attr){
var attrVal = utils.text(attr.val);
attrVal = '\'' + attrVal.replace(/\\'/g, "") + '\'';
//attrVal = '\'test\' + escape(title) + \'\'';
if (attr.name == 'class') {
classes.push('(' + attr.val + ')');
classes.push('(' + attrVal + ')');
} else {
var pair = "'" + attr.name + "':(" + attr.val + ')';
var pair = "'" + attr.name + "':(" + attrVal + ')';
buf.push(pair);
}
});
Expand Down

0 comments on commit 8208868

Please sign in to comment.