* Renders template with given data. * * This method automaticaly applies layout if set. * * @param {string} file - Template filename. * @param {object} data - Template variables (doesn't have to be object, but passing variables dictionary is best way and most common use).
(file, data)
| 65 | * @return {string} Rendered template. |
| 66 | */ |
| 67 | render(file, data) { |
| 68 | // main content |
| 69 | let content = this.partial(file, data); |
| 70 | |
| 71 | // apply layout |
| 72 | if (this.layout) { |
| 73 | data.content = content; |
| 74 | content = this.partial(this.layout, data); |
| 75 | } |
| 76 | |
| 77 | return content; |
| 78 | } |
| 79 | } |
| 80 | exports.Template = Template; |
no test coverage detected