diff --git a/src/twig.logic.js b/src/twig.logic.js index bb100b2f..a1ee5f4c 100644 --- a/src/twig.logic.js +++ b/src/twig.logic.js @@ -39,7 +39,9 @@ module.exports = function (Twig) { embed: 'Twig.logic.type.embed', endembed: 'Twig.logic.type.endembed', 'with': 'Twig.logic.type.with', - endwith: 'Twig.logic.type.endwith' + endwith: 'Twig.logic.type.endwith', + verbatim: 'Twig.logic.type.verbatim', + endverbatim: 'Twig.logic.type.endverbatim' }; @@ -1247,6 +1249,30 @@ module.exports = function (Twig) { regex: /^endwith$/, next: [ ], open: false + }, + { + type: Twig.logic.type.verbatim, + regex: /^verbatim/, + next: [ + Twig.logic.type.endverbatim + ], + open: true, + + // Return the output without any parse + parse: function (token, context, chain) { + return { + chain: chain, + output: context + }; + } + }, + + // Add the {% endverbatim %} token + { + type: Twig.logic.type.endverbatim, + regex: /^endverbatim$/, + next: [ ], + open: false } ]; diff --git a/test/test.verbatim.js b/test/test.verbatim.js new file mode 100644 index 00000000..263f82c8 --- /dev/null +++ b/test/test.verbatim.js @@ -0,0 +1,10 @@ +var Twig = (Twig || require("../twig")).factory(), + twig = twig || Twig.twig; + +describe("Twig.js Verbatim ->", function () { + + it("should return raw content", function () { + twig({data: '{% verbatim %}{{ variable }}{% endverbatim %}'}).render({ 'variable': 42 }).should.equal('{{ variable }}'); + }); + +});