diff options
Diffstat (limited to 'lib/models')
-rw-r--r-- | lib/models/__tests__/templateBlock.js | 30 | ||||
-rw-r--r-- | lib/models/templateBlock.js | 2 |
2 files changed, 26 insertions, 6 deletions
diff --git a/lib/models/__tests__/templateBlock.js b/lib/models/__tests__/templateBlock.js index 52f6407..5265bf6 100644 --- a/lib/models/__tests__/templateBlock.js +++ b/lib/models/__tests__/templateBlock.js @@ -8,7 +8,10 @@ describe('TemplateBlock', function() { describe('create', function() { pit('must initialize a simple TemplateBlock from a function', function() { var templateBlock = TemplateBlock.create('sayhello', function(block) { - return '<p>Hello, World!</p>'; + return { + body: '<p>Hello, World!</p>', + parse: true + }; }); // Check basic templateBlock properties @@ -32,7 +35,10 @@ describe('TemplateBlock', function() { describe('getShortcuts', function() { it('must return undefined if no shortcuts', function() { var templateBlock = TemplateBlock.create('sayhello', function(block) { - return '<p>Hello, World!</p>'; + return { + body: '<p>Hello, World!</p>', + parse: true + }; }); expect(templateBlock.getShortcuts()).not.toBeDefined(); @@ -63,7 +69,10 @@ describe('TemplateBlock', function() { describe('toNunjucksExt()', function() { pit('must create a valid nunjucks extension', function() { var templateBlock = TemplateBlock.create('sayhello', function(block) { - return '<p>Hello, World!</p>'; + return { + body: '<p>Hello, World!</p>', + parse: true + }; }); // Create a fresh Nunjucks environment @@ -83,7 +92,10 @@ describe('TemplateBlock', function() { pit('must apply block arguments correctly', function() { var templateBlock = TemplateBlock.create('sayhello', function(block) { - return '<'+block.kwargs.tag+'>Hello, '+block.kwargs.name+'!</'+block.kwargs.tag+'>'; + return { + body: '<'+block.kwargs.tag+'>Hello, '+block.kwargs.name+'!</'+block.kwargs.tag+'>', + parse: true + }; }); // Create a fresh Nunjucks environment @@ -105,7 +117,10 @@ describe('TemplateBlock', function() { var templateBlock = TemplateBlock.create('sayhello', function(block) { return Promise() .then(function() { - return 'Hello ' + block.body; + return { + body: 'Hello ' + block.body, + parse: true + }; }); }); @@ -135,7 +150,10 @@ describe('TemplateBlock', function() { nested[blk.name] = blk.body.trim(); }); - return '<p class="yoda">'+nested.end+' '+nested.start+'</p>'; + return { + body: '<p class="yoda">'+nested.end+' '+nested.start+'</p>', + parse: true + }; } }); diff --git a/lib/models/templateBlock.js b/lib/models/templateBlock.js index ab4cf3e..36f7c5b 100644 --- a/lib/models/templateBlock.js +++ b/lib/models/templateBlock.js @@ -71,6 +71,8 @@ TemplateBlock.prototype.getExtensionName = function() { @return {Nunjucks.Extension} */ TemplateBlock.prototype.toNunjucksExt = function(mainContext, blocksOutput) { + blocksOutput = blocksOutput || {}; + var that = this; var name = this.getName(); var endTag = this.getEndTag(); |