Ver código fonte

Change delimiter should honour pragmas

tags/0.5.0-vsc
Sahab Yazdani 15 anos atrás
pai
commit
d2e4a628c2
2 arquivos alterados com 14 adições e 1 exclusões
  1. +2
    -0
      mustache.js
  2. +12
    -1
      test/unit.js

+ 2
- 0
mustache.js Ver arquivo

@@ -398,6 +398,7 @@ var Mustache = (function(undefined) {
, state.partials , state.partials
); );
new_state.metrics.partial = variable; new_state.metrics.partial = variable;
// TODO: Determine if partials should inherit pragma state from parent
program = compile(new_state); program = compile(new_state);
state.partials[variable] = function(context, send_func) { state.partials[variable] = function(context, send_func) {
@@ -552,6 +553,7 @@ var Mustache = (function(undefined) {
new_state.metrics.character = state.metrics.character + token.length; new_state.metrics.character = state.metrics.character + token.length;
new_state.metrics.partial = state.metrics.partial; new_state.metrics.partial = state.metrics.partial;
new_state.section = state.section; new_state.section = state.section;
new_state.pragmas = state.pragmas;
if (new_state.section) { if (new_state.section) {
new_state.section.template_buffer.push(token); new_state.section.template_buffer.push(token);
} }


+ 12
- 1
test/unit.js Ver arquivo

@@ -499,8 +499,19 @@ test("'%' (Pragmas)", function() {
{ dataSet: [ 'Object 1', 'Object 2', 'Object 3' ] }, { dataSet: [ 'Object 1', 'Object 2', 'Object 3' ] },
{} {}
), ),
"Object 1:Object 2:Object 3:"
"Object 1:Object 2:Object 3:",
'Default behaviour for IMPLICIT ITERATOR'
); );
equals(
Mustache.to_html(
'{{%IMPLICIT-ITERATOR iterator=rob}}{{=<% %>=}}<%#dataSet%><%rob%>:<%/dataSet%>',
{ dataSet: [ 'Object 1', 'Object 2', 'Object 3' ] },
{}
),
"Object 1:Object 2:Object 3:",
'Change Delimiter and Pragma mixes'
);
}); });


test("Empty", function() { test("Empty", function() {


Carregando…
Cancelar
Salvar