Permalink
Browse files

Merge remote branch 'guille/master' into integration

  • Loading branch information...
2 parents 0fa6466 + 4ac79d6 commit 5b2833456b5a19294326b4ff108e347a56599edb @tj tj committed Jul 3, 2010
Showing with 5 additions and 3 deletions.
  1. +3 −3 lib/jade.js
  2. +2 −0 test/jade.test.js
View
@@ -225,7 +225,7 @@ Parser.prototype = {
}
// Attributes
- if (captures = /^\(([^\)]+)\)/.exec(this.input)) {
+ if (captures = /^\( *([^\)]+) *\)/.exec(this.input)) {
var tok = token('attrs'),
attrs = tok.val.split(/ *, */);
tok.attrs = {};
@@ -614,7 +614,7 @@ function interpolate(str){
*
* Options:
*
- * - `scope` Evaluation scope (`this`)
+ * - `scope` Evaluation scope (`this`). Also referred to as `context`
* - `locals` Local variable object
* - `filename` Used in exceptions, and required by `cache`
* - `cache` Cache intermediate JavaScript in memory keyed by `filename`
@@ -689,7 +689,7 @@ exports.render = function(str, options){
try {
var _ = { lineno: 1 };
- return fn.call(options.scope,
+ return fn.call(options.scope || options.context,
options.locals || {},
attrs,
escape,
View
@@ -284,6 +284,7 @@ module.exports = {
assert.equal('<img src="/foo.png" alt="just some foo" />', render('img(src = "/foo.png", alt = "just some foo")'));
assert.equal('<label for="name"></label>', render('label(for="name")'));
+ assert.equal('<div class="b:a=c"></div>', render("div(class='b:a=c')"), 'Test attrs that contain attr separators');
},
'test code attrs': function(assert){
@@ -295,6 +296,7 @@ module.exports = {
'test code attrs class': function(assert){
assert.equal('<p class="tj"></p>', render('p(class: name)', { locals: { name: 'tj' }}));
+ assert.equal('<p class="tj"></p>', render('p( class: name )', { locals: { name: 'tj' }}));
assert.equal('<p class="default"></p>', render('p(class: name || "default")', { locals: { name: null }}));
assert.equal('<p class="foo default"></p>', render('p.foo(class: name || "default")', { locals: { name: null }}));
assert.equal('<p class="foo default"></p>', render('p(class: name || "default").foo', { locals: { name: null }}));

0 comments on commit 5b28334

Please sign in to comment.