2015-04-18 105 views

回答

0

是的!只要改變prototype

var Mustache = require('mustache'); 

Mustache.Writer.prototype.renderTokens = function (tokens, context, partials, originalTemplate) { 
    var buffer = ''; 

    var token, symbol, value, tag; 
    for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) { 
    value = undefined; 
    token = tokens[i]; 
    symbol = token[0]; 
    tag = value = mustache.tags[0] + token[1] + mustache.tags[1]; 

    if (symbol === '#') value = this._renderSection(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 = tag; 
    else if (symbol === 'name') value = tag; 
    else if (symbol === 'text') value = this._rawValue(token); 

    if (value !== undefined) 
     buffer += value; 
    } 

    return buffer; 
}; 

現在,它只能與諧音輸出解析成一個模板。

相關問題