瀏覽代碼

Move invariant outside of the function

tags/0.5.0-vsc
Sahab Yazdani 15 年之前
父節點
當前提交
5085dc23a8
共有 1 個檔案被更改,包括 8 行新增12 行删除
  1. +8
    -12
      mustache.js

+ 8
- 12
mustache.js 查看文件

@@ -255,22 +255,18 @@ var Mustache = (function(undefined) {
return state;
}
var pragma_directives = {
'IMPLICIT-ITERATOR': function(state, options) {
state.pragmas['IMPLICIT-ITERATOR'] = {iterator: ((options || {iterator:undefined}).iterator) || '.'};
}
};
function pragmas(state) {
/* includes tag */
function includes(needle, haystack) {
return haystack.indexOf('{{' + needle) !== -1;
}
var directives = {
'IMPLICIT-ITERATOR': function(options) {
state.pragmas['IMPLICIT-ITERATOR'] = {iterator: '.'};
if (options) {
state.pragmas['IMPLICIT-ITERATOR'].iterator = options['iterator'];
}
}
};
// no pragmas, easy escape
if(!includes("%", state.template)) {
return state.template;
@@ -294,8 +290,8 @@ var Mustache = (function(undefined) {
}
}
if (is_function(directives[pragma])) {
directives[pragma](options);
if (is_function(pragma_directives[pragma])) {
pragma_directives[pragma](state, options);
} else {
throw create_error(undefined, 'This implementation of mustache does not implement the "' + pragma + '" pragma.');
}


Loading…
取消
儲存