Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding parsing error for raw tag when no endraw found.

  • Loading branch information...
commit d266f04fd5f5f565e436009e6e3c16814e3ac7fd 1 parent c01f540
@paularmstrong authored
Showing with 12 additions and 1 deletion.
  1. +4 −0 lib/parser.js
  2. +8 −1 tests/tags.test.js
View
4 lib/parser.js
@@ -255,6 +255,10 @@ exports.parse = function (data, tags, autoescape) {
stack[index].push(token);
}
+ if (inRaw !== false) {
+ throw new Error('Missing expected end tag for "raw" on line ' + curline + '.');
+ }
+
if (index !== 0) {
lastToken = _.last(stack[stack.length - 2]);
throw new Error('Missing end tag for "' + lastToken.name + '" that was opened on line ' + lastToken.line + '.');
View
9 tests/tags.test.js
@@ -397,7 +397,7 @@ exports.filter = testCase({
exports.raw = testCase({
setUp: function (callback) {
- swig.init({});
+ swig.init({ allowErrors: true });
callback();
},
@@ -421,5 +421,12 @@ exports.raw = testCase({
test.strictEqual(tpl({}), input);
test.done();
+ },
+
+ 'errors when no endraw tag found': function (test) {
+ test.throws(function () {
+ swig.compile('{% raw %}{{ foobar }}');
+ }, Error);
+ test.done();
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.