Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
more specific type check for TemplateRefs, allow variables for extends
  • Loading branch information
jlongster committed Oct 3, 2012
1 parent d68622c commit d23181f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/parser.js
Expand Up @@ -192,9 +192,9 @@ var Parser = Object.extend({
var node = new nodeType(tag.lineno, tag.colno);

node.template = this.parsePrimary();
if(!((node.template instanceof nodes.Literal ||
node.template instanceof nodes.Value) &&
lib.isString(node.template.value))) {
if(!(node.template instanceof nodes.Literal &&
lib.isString(node.template.value)) &&
!(node.template instanceof nodes.Symbol)) {
this.fail('parseExtends: string or value expected');
}

Expand Down
9 changes: 6 additions & 3 deletions tests/test.js
Expand Up @@ -585,6 +585,10 @@ describe('compiler', function() {
'{% block block1 %}BAR{% endblock %}' +
'{% block block2 %}BAZ{% endblock %}');
s.should.equal('FooBARBAZFizzle');

s = render('hola {% extends tmpl %} hizzle mumble',
{ tmpl: 'base.html' });
s.should.equal('FooBarBazFizzle');
});

it('should render parent blocks with super()', function() {
Expand All @@ -601,9 +605,8 @@ describe('compiler', function() {
{ name: 'james' });
s.should.equal('hello world FooInclude james');


s = render('hello world {% include templ %}',
{ name: 'thedude', templ: "include.html" });
s = render('hello world {% include tmpl %}',
{ name: 'thedude', tmpl: "include.html" });
s.should.equal('hello world FooInclude thedude');
});

Expand Down

0 comments on commit d23181f

Please sign in to comment.