Skip to content

Commit

Permalink
betetr var
Browse files Browse the repository at this point in the history
  • Loading branch information
hefangshi committed Jul 14, 2016
1 parent 4d65486 commit 05a4f6f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tags/pagelet.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports.compile = function (compiler, args, content, parents, options, blockName
attr[args[i].k] = args[i].v;
}
attr.mode = attr.mode || 'async';
var attrStr = JSON.stringify(attr).replace(/"<<VAR:(.*?)>>"/g, '(typeof _ctx.$1 !== "undefined" && typeof _ctx.$1 !== "null") ? _ctx.$1 : ((typeof $1 !== "undefined" && typeof $1 !== "null") ? $1 : "")');
var attrStr = JSON.stringify(attr).replace(/"<<VAR:(.*?)>>"/g, '((typeof _ctx.$1 !== "undefined" && typeof _ctx.$1 !== "null") ? _ctx.$1 : ((typeof $1 !== "undefined" && typeof $1 !== "null") ? $1 : ""))');
var compiledContent = compiler(content, parents, options, blockName);
var output = '_output += _swig._w(_ctx._yog, function(_ctx) { var _output = ""; ' + compiledContent +
';return _output;}, ' + attrStr + ', ' + JSON.stringify(options) + ')(_ctx);';
Expand Down
4 changes: 2 additions & 2 deletions tags/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ exports.compile = function (compiler, args) {
if (w.k && w.k !== 'data') {
w_args[w.k] = w.v;
} else if (w.k == 'data') {
withData = JSON.stringify(w.v).replace(/"<<VAR:(.*?)>>"/g, '(typeof _ctx.$1 !== "undefined" && typeof _ctx.$1 !== "null") ? _ctx.$1 : ((typeof $1 !== "undefined" && typeof $1 !== "null") ? $1 : "")');
withData = JSON.stringify(w.v).replace(/"<<VAR:(.*?)>>"/g, '((typeof _ctx.$1 !== "undefined" && typeof _ctx.$1 !== "null") ? _ctx.$1 : ((typeof $1 !== "undefined" && typeof $1 !== "null") ? $1 : ""))');
}
});
if (!withData) {
withData = w;
}
// 处理_VAR_:标记,将其转变为获取ctx变量
var w_args_str = JSON.stringify(w_args).replace(/"<<VAR:(.*?)>>"/g, '(typeof _ctx.$1 !== "undefined" && typeof _ctx.$1 !== "null") ? _ctx.$1 : ((typeof $1 !== "undefined" && typeof $1 !== "null") ? $1 : "")');
var w_args_str = JSON.stringify(w_args).replace(/"<<VAR:(.*?)>>"/g, '((typeof _ctx.$1 !== "undefined" && typeof _ctx.$1 !== "null") ? _ctx.$1 : ((typeof $1 !== "undefined" && typeof $1 !== "null") ? $1 : ""))');
return (ignore ? ' try {\n' : '') +
'_output += _swig._w(_ctx._yog, ' + file + ',' + w_args_str + ', {' +
'resolveFrom: "' + parentFile + '"' +
Expand Down

0 comments on commit 05a4f6f

Please sign in to comment.