Permalink
Browse files

Adding tests for using extends with context vars

  • Loading branch information...
1 parent 17a684d commit d1deac2e3f0973cb122838aa3565befc5a8a43ee Taka Kojima committed Jul 28, 2012
Showing with 37 additions and 0 deletions.
  1. +22 −0 index.test.js
  2. +9 −0 tests/templates/extends_base2.html
  3. +6 −0 tests/templates/extends_dynamic.html
View
@@ -70,6 +70,28 @@ exports.compileFile = testCase({
test.done();
},
+ 'using context var with extends tag' : function (test) {
+ swig.init({
+ root: __dirname + '/tests/templates',
+ allowErrors: true
+ });
+
+ var tpl, r1, r2, r3, r4;
+
+ tpl = swig.compileFile('extends_dynamic.html');
+ r1 = tpl.render({baseTmpl: "extends_base.html"});
+ r2 = tpl.render({baseTmpl: "extends_base2.html"});
+ r3 = tpl.render({baseTmpl: "extends_base.html"});
+ r4 = tpl.render({baseTmpl: "extends_base2.html"});
+
+ test.strictEqual(r1,r3, "this should not throw");
+ test.strictEqual(r2,r4, "this should not throw");
+
+ test.notEqual(r1, r2, "these should not be equal, as they use different base templates.");
+
+ test.done();
+ },
+
'absolute path': function (test) {
swig.init({
root: __dirname + '/tests/templates',
@@ -0,0 +1,9 @@
+This is from the "extends_base2.html" template.
+
+{% block one %}
+ This is the default content in block 'one'
+{% endblock %}
+
+{% block two %}
+ This is the default content in block 'two'
+{% endblock %}
@@ -0,0 +1,6 @@
+{% extends baseTmpl %}
+This is content from "extends_dynamic.html", you should not see it
+
+{% block one %}
+ This is the "extends_dynamic.html" content in block 'one'
+{% endblock %}

0 comments on commit d1deac2

Please sign in to comment.