Explorar el Código

Move invariant outside of the function

tags/0.5.0-vsc
Sahab Yazdani hace 15 años
padre
commit
5085dc23a8
Se han modificado 1 ficheros con 8 adiciones y 12 borrados
  1. +8
    -12
      mustache.js

+ 8
- 12
mustache.js Ver fichero

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


Cargando…
Cancelar
Guardar