Skip to content

Commit

Permalink
Added frame variables reference support in 'set'.
Browse files Browse the repository at this point in the history
  • Loading branch information
panta committed Nov 13, 2012
1 parent 3592f7f commit d7909d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler.js
Expand Up @@ -276,7 +276,7 @@ var Compiler = Object.extend({
var id = this.tmpid(); var id = this.tmpid();


this.emit('var ' + id + ' = '); this.emit('var ' + id + ' = ');
this._compileExpression(node.value); this._compileExpression(node.value, frame);
this.emitLine(';'); this.emitLine(';');


for(var i=0; i<node.targets.length; i++) { for(var i=0; i<node.targets.length; i++) {
Expand Down
6 changes: 6 additions & 0 deletions tests/compiler.js
Expand Up @@ -315,6 +315,12 @@ describe('compiler', function() {
s.should.equal('bar'); s.should.equal('bar');
}); });


it('should compile set with frame references', function() {
var s = render('{% set username = user.name %}{{ username }}',
{ user: { name: 'james' } });
s.should.equal('james');
});

it('should throw errors', function() { it('should throw errors', function() {
(function() { (function() {
render('{% from "import.html" import boozle %}'); render('{% from "import.html" import boozle %}');
Expand Down

0 comments on commit d7909d4

Please sign in to comment.