Explorar el Código

Fix change delimiter inside section

tags/0.5.0-vsc
Sahab Yazdani hace 15 años
padre
commit
6c2d074f14
Se han modificado 2 ficheros con 23 adiciones y 6 borrados
  1. +10
    -5
      mustache.js
  2. +13
    -1
      test/unit.js

+ 10
- 5
mustache.js Ver fichero

@@ -482,17 +482,22 @@ var Mustache = (function(undefined) {
throw new Error('Malformed change delimiter token: ' + token); throw new Error('Malformed change delimiter token: ' + token);
} }
var context = create_compiler_state(
var new_state = create_compiler_state(
state.tokens.slice(state.cursor+1).join('') state.tokens.slice(state.cursor+1).join('')
, state.partials , state.partials
, matches[1] , matches[1]
, matches[2]); , matches[2]);
context.code = state.code;
context.send_code_func = state.send_code_func;
new_state.code = state.code;
new_state.send_code_func = state.send_code_func;
new_state.parser = state.parser;
new_state.section = state.section;
if (new_state.section) {
new_state.section.template_buffer.push(token);
}
state.cursor = state.tokens.length; // finish off this level state.cursor = state.tokens.length; // finish off this level
compile(context, true);
compile(new_state, true);
} }
function begin_section(state, token, mark) { function begin_section(state, token, mark) {


+ 13
- 1
test/unit.js Ver fichero

@@ -399,6 +399,18 @@ test("'=' (Set Delimiter)", function() {
'*\nIt worked the first time.\n* And it worked the second time.\n\n* Then, surprisingly, it worked the third time.\n\n* Fourth time also fine!.', '*\nIt worked the first time.\n* And it worked the second time.\n\n* Then, surprisingly, it worked the third time.\n\n* Fourth time also fine!.',
'Simple Set Delimiter' 'Simple Set Delimiter'
); );
equals(
Mustache.to_html(
'{{#noData}}{{=~~ ~~=}}Set Change Delimiter ~~data~~ ~~={{ }}=~~{{/noData}}'
, {
noData: true
, data: false
}
, {}
)
, 'Set Change Delimiter false '
, 'Change Delimiter inside Section');
}); });


test("'!' (Comments)", function() { test("'!' (Comments)", function() {
@@ -619,4 +631,4 @@ test("Regression Suite", function() {
, 'foobar' , 'foobar'
, 'Nested Sections with the same name' , 'Nested Sections with the same name'
); );
});
});

Cargando…
Cancelar
Guardar