Просмотр исходного кода

Fix change delimiter inside section

tags/0.5.0-vsc
Sahab Yazdani 15 лет назад
Родитель
Сommit
6c2d074f14
2 измененных файлов: 23 добавлений и 6 удалений
  1. +10
    -5
      mustache.js
  2. +13
    -1
      test/unit.js

+ 10
- 5
mustache.js Просмотреть файл

@@ -482,17 +482,22 @@ var Mustache = (function(undefined) {
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.partials
, matches[1]
, 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
compile(context, true);
compile(new_state, true);
}
function begin_section(state, token, mark) {


+ 13
- 1
test/unit.js Просмотреть файл

@@ -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!.',
'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() {
@@ -619,4 +631,4 @@ test("Regression Suite", function() {
, 'foobar'
, 'Nested Sections with the same name'
);
});
});

Загрузка…
Отмена
Сохранить