UNPKG

861 BJavaScriptView Raw
1var exports = module.exports;
2
3/**
4 * trigger the load of FIS, it means add a js/css file to the page.
5 *
6 * @alias require
7 *
8 * @example
9 * // if `namespace` = `user`
10 * // load mod.js
11 * {%require "user:static/mod.js"%}
12 *
13 * @param {string|var} id the resource `id` of the FIS system.
14 */
15exports.compile = function(compiler, args, content, parents, options, blockName) {
16 var code = '_ctx._yog.load(' + args[0] + ', ' + args[1] + ');'
17 return code;
18};
19
20exports.parse = function(str, line, parser, types) {
21 parser.on(types.STRING, function (token) {
22 this.out.unshift(token.match);
23 });
24 parser.on(types.VAR, function (token) {
25 if (token.match === 'external') {
26 this.out.push(true);
27 }else {
28 this.out.unshift('_ctx.' + token.match);
29 }
30 });
31 return true;
32};
33
34exports.ends = false;