107 unmodified lines
Expand all
/**
* Render _view_ with _options_.
*
* Views are looked up relative to the'views' path setting.
* View filenames should conform to ANY.ENGINE.TYPE so for example
* 'layout.ejs.html', 'ejs' represents the template engine, 'html'
* View filenames should conform to NAME.TYPE.ENGINE so for example
* 'layout.html.ejs', 'ejs' represents the template engine, 'html'
* represents the type of content being rendered, which is then passed
* to contentType().
*
* Engines must export a render() method accepting the template string
parts = view.split('.'),
engine = parts.last,
contentType = parts.slice(-2)[0],
layout = options.layout === undefined ? 'layout' : options.layout
// >>> DEPRECATED: remove in 0.9.0
if (['haml', 'sass', 'ejs'].indexOf(contentType) !== -1) {
Ext.warn('views now take the form NAME.TYPE.ENGINE such as "page.html.haml" instead of "page.haml.html".' +
' Will be removed in 0.9.0')
var swap = contentType
contentType = engine
engine = swap
path = set(type) + '/' + parts.first + '.' + contentType + '.' + engine
}
// <<<
content = cache[type][path] || fs.readFileSync(path)
var content = cache[type][path] || fs.readFileSync(path)
options.context = options.context || this
content = (engines[engine] = engines[engine] || require(engine)).render(content, options)
if (type === 'views') this.contentType(contentType)
if (layout)