yahoi
Version:
Yet Another Highly Opinionated Isomorphic Framework
23 lines (20 loc) • 508 B
JavaScript
import fs from 'fs';
import Handlebars from 'handlebars';
export default class ViewRenderer {
constructor(props) {
this.filePath = props.filePath;
this.data = props.data;
}
render() {
return new Promise((fulfill, reject) => {
fs.readFile(`${this.filePath}.handlebars`, 'utf8', (err, source) => {
if (err) {
reject(err)
} else {
let template = Handlebars.compile(source);
fulfill(template(this.data));
}
});
});
}
}