New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document ejs.renderFile() method #52
Comments
Does renderFile() method work at all? function insertTemplate(data) {
getTemplate('/tpl/template.ejs', function addTemplate(err, tpl) {
if (err) {
throw err;
}
var tpl = require('ejs').render(tpl, {data: data});
$(tpl).prependTo('div.dataItems');
});
}
function getTemplate(file, callback) {
$.ajax(file, {
type: 'GET',
success: function(data, textStatus, xhr) {
return callback(null, data);
},
error: function(xhr, textStatus, error) {
return callback(error);
}
});
} |
@apptous-seb it's for node lol not the client :p |
@visionmedia I am about the ejs.js in the root folder. Isn't it for the client side? |
no, |
Yes, I understand that. And understand fs.readFileSync doesn't work on client. And "fs" object itself is present in the client script, but it is a mock empty object: function require(p){
if ('fs' == p) return {};
... And now the renderFile() method can not work in client side version of ejs.js. P.S. Sorry for confusion, I worked on client side today and did not have any doubts that this issue is about the client side ejs ))) |
so it doesn't error on |
OK, I see now. So what do you think about the changing fs.readFileSync to fs.readFile in the renderFile() method and providing the client-side version of fs.readFile()? I could implement this and do a pull request. |
I don't see a point, it's (usually) a poor choice to do additional requests just for templates, it does depend though, but I think that's not a concern for EJS, just do XHR if you need to etc.. |
The method renderFile() method is not documented in Readme.md file.
Please advise if this is not the best place to report this kind of issues.
Thanks.
The text was updated successfully, but these errors were encountered: