-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (26 loc) · 821 Bytes
/
index.js
File metadata and controls
30 lines (26 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* eslint no-var:0 */
'use strict';
module.exports = CaptureTag;
function CaptureTag() {
this.tags = ['capture'];
this.parse = parse;
this.run = run;
function parse(parser, nodes) {
var tok;
var args;
var body;
tok = parser.nextToken();
args = parser.parseSignature(null, true);
parser.advanceAfterBlockEnd(tok.value);
body = parser.parseUntilBlocks('endcapture');
parser.advanceAfterBlockEnd();
return new nodes.CallExtension(this, 'run', args, [body]);
}
function run(context, args, body) {
if (args && 'as' in args) {
context.ctx[args.as] = body(); // eslint-disable-line no-param-reassign
} else {
throw new Error('Expected an "as" argument in capture tag');
}
}
}