fix
This commit is contained in:
24
book/node_modules/nunjucks-do/index.js
generated
vendored
Normal file
24
book/node_modules/nunjucks-do/index.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
var vm = require('vm');
|
||||
|
||||
module.exports = function(nunjucks) {
|
||||
return function DoExtension(_env) {
|
||||
this.tags = ['do'];
|
||||
|
||||
this.parse = function(parser, nodes, lexer) {
|
||||
var tok = parser.nextToken();
|
||||
var args = parser.parseSignature(null, true);
|
||||
parser.advanceAfterBlockEnd(tok.value);
|
||||
var body = parser.parseUntilBlocks('enddo');
|
||||
parser.advanceAfterBlockEnd();
|
||||
|
||||
return new nodes.CallExtension(this, 'run', args, [body]);
|
||||
};
|
||||
|
||||
this.run = function(context, body) {
|
||||
var js = body();
|
||||
|
||||
vm.runInNewContext(js, context.ctx);
|
||||
return '';
|
||||
};
|
||||
};
|
||||
};
|
Reference in New Issue
Block a user