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