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

[#678]: Fix partials were not rendering tokens when not using default tags

pull/679/head
stackchain 7 лет назад
Родитель
Сommit
71bfc6e2a2
2 измененных файлов: 10 добавлений и 5 удалений
  1. +5
    -0
      CHANGELOG.md
  2. +5
    -5
      mustache.js

+ 5
- 0
CHANGELOG.md Просмотреть файл

@@ -3,6 +3,11 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/). This project adheres to [Semantic Versioning](http://semver.org/).


## [3.0.1] / 28 September 2018

* [#678]: Fix partials were not rendering tokens when not using default tags, by [@stackchain].


## [3.0.0] / 16 September 2018 ## [3.0.0] / 16 September 2018


We are very happy to announce a new major version of mustache.js. We want to be very careful not to break projects We are very happy to announce a new major version of mustache.js. We want to be very careful not to break projects


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

@@ -514,7 +514,7 @@
Writer.prototype.render = function render (template, view, partials, tags) { Writer.prototype.render = function render (template, view, partials, tags) {
var tokens = this.parse(template, tags); var tokens = this.parse(template, tags);
var context = (view instanceof Context) ? view : new Context(view); var context = (view instanceof Context) ? view : new Context(view);
return this.renderTokens(tokens, context, partials, template);
return this.renderTokens(tokens, context, partials, template, tags);
}; };


/** /**
@@ -526,7 +526,7 @@
* If the template doesn't use higher-order sections, this argument may * If the template doesn't use higher-order sections, this argument may
* be omitted. * be omitted.
*/ */
Writer.prototype.renderTokens = function renderTokens (tokens, context, partials, originalTemplate) {
Writer.prototype.renderTokens = function renderTokens (tokens, context, partials, originalTemplate, tags) {
var buffer = ''; var buffer = '';


var token, symbol, value; var token, symbol, value;
@@ -537,7 +537,7 @@


if (symbol === '#') value = this.renderSection(token, context, partials, originalTemplate); if (symbol === '#') value = this.renderSection(token, context, partials, originalTemplate);
else if (symbol === '^') value = this.renderInverted(token, context, partials, originalTemplate); else if (symbol === '^') value = this.renderInverted(token, context, partials, originalTemplate);
else if (symbol === '>') value = this.renderPartial(token, context, partials, originalTemplate);
else if (symbol === '>') value = this.renderPartial(token, context, partials, tags);
else if (symbol === '&') value = this.unescapedValue(token, context); else if (symbol === '&') value = this.unescapedValue(token, context);
else if (symbol === 'name') value = this.escapedValue(token, context); else if (symbol === 'name') value = this.escapedValue(token, context);
else if (symbol === 'text') value = this.rawValue(token); else if (symbol === 'text') value = this.rawValue(token);
@@ -592,12 +592,12 @@
return this.renderTokens(token[4], context, partials, originalTemplate); return this.renderTokens(token[4], context, partials, originalTemplate);
}; };


Writer.prototype.renderPartial = function renderPartial (token, context, partials) {
Writer.prototype.renderPartial = function renderPartial (token, context, partials, tags) {
if (!partials) return; if (!partials) return;


var value = isFunction(partials) ? partials(token[1]) : partials[token[1]]; var value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
if (value != null) if (value != null)
return this.renderTokens(this.parse(value), context, partials, value);
return this.renderTokens(this.parse(value, tags), context, partials, value);
}; };


Writer.prototype.unescapedValue = function unescapedValue (token, context) { Writer.prototype.unescapedValue = function unescapedValue (token, context) {


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