1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | exports.compile = function(compiler, args, content, parents, options, blockName) {
|
8 | var attrs = [];
|
9 | var framework;
|
10 |
|
11 | args.forEach(function(arg) {
|
12 | if (!arg.key) {
|
13 | return;
|
14 | } else if (arg.key === "attrs") {
|
15 | attrs.push(arg.value);
|
16 | } else {
|
17 | attrs.push(arg.key + "=" + arg.raw);
|
18 | }
|
19 | });
|
20 |
|
21 | var code = compiler(content, parents, options, blockName);
|
22 | return '_output += "<body ' + (attrs.join(' ').replace(/"/g, "\\\"")) + '>";' + code + '_output += _ctx._yog.JS_HOOK + "</body>";';
|
23 | };
|
24 |
|
25 | exports.parse = function(str, line, parser, types, stack, opts) {
|
26 | var key = '',
|
27 | assign;
|
28 |
|
29 | parser.on(types.STRING, function(token) {
|
30 | if (key && assign) {
|
31 | var raw = token.match;
|
32 | var val = raw.substring(1, raw.length - 1);
|
33 |
|
34 | this.out.push({
|
35 | key: key,
|
36 | value: val,
|
37 | raw: raw
|
38 | });
|
39 |
|
40 | key = assign = '';
|
41 | }
|
42 | });
|
43 |
|
44 | parser.on(types.ASSIGNMENT, function(token) {
|
45 | if (token.match === "=") {
|
46 | assign = true;
|
47 | }
|
48 | });
|
49 |
|
50 | parser.on(types.NUMBER, function(token) {
|
51 | var val = token.match;
|
52 |
|
53 | if (val && /^\-/.test(val) && key) {
|
54 | key += val;
|
55 | }
|
56 | });
|
57 |
|
58 | parser.on(types.OPERATOR, function(token) {
|
59 | var val = token.match;
|
60 |
|
61 | if (val === '-' && key) {
|
62 | key += val;
|
63 | }
|
64 | });
|
65 |
|
66 | parser.on(types.VAR, function(token) {
|
67 | key += token.match;
|
68 | assign = false;
|
69 | return false;
|
70 | });
|
71 |
|
72 | return true;
|
73 | };
|
74 |
|
75 | exports.ends = true; |
\ | No newline at end of file |