소스 검색

Cache partials by template, not by name

Fixes #257
tags/0.7.1
Michael Jackson 13 년 전
부모
커밋
658f9e051f
1개의 변경된 파일8개의 추가작업 그리고 6개의 파일을 삭제
  1. +8
    -6
      mustache.js

+ 8
- 6
mustache.js 파일 보기

@@ -193,24 +193,26 @@ var Mustache;
};

Writer.prototype.compile = function (template, tags) {
return this._compile(this._cache, template, template, tags);
return this._compile(template, tags);
};

Writer.prototype.compilePartial = function (name, template, tags) {
return this._compile(this._partialCache, name, template, tags);
var fn = this._compile(template, tags);
this._partialCache[name] = fn;
return fn;
};

Writer.prototype.render = function (template, view, partials) {
return this.compile(template)(view, partials);
};

Writer.prototype._compile = function (cache, key, template, tags) {
if (!cache[key]) {
Writer.prototype._compile = function (template, tags) {
if (!this._cache[template]) {
var tokens = exports.parse(template, tags);
var fn = compileTokens(tokens);

var self = this;
cache[key] = function (view, partials) {
this._cache[template] = function (view, partials) {
if (partials) {
if (typeof partials === "function") {
self._loadPartial = partials;
@@ -225,7 +227,7 @@ var Mustache;
};
}

return cache[key];
return this._cache[template];
};

Writer.prototype._section = function (name, context, text, callback) {


불러오는 중...
취소
저장