Skip to content
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

ejs.render #217

Open
EasonWang01 opened this issue Mar 22, 2016 · 1 comment
Open

ejs.render #217

EasonWang01 opened this issue Mar 22, 2016 · 1 comment

Comments

@EasonWang01
Copy link

I saw an example here
https://github.com/tj/ejs/blob/master/examples/client.html

Is it possible to change

var html = ejs.render(users, { names: names });

to

var html = ejs.render("home.ejs", { names: names });

For using an outside ejs file,rather than a ejs script inside HTML?

@RyanZim
Copy link

RyanZim commented Mar 25, 2016

This version of EJS is no longer supported. https://github.com/mde/ejs/ (http://ejs.co) is the current version. Regarding your question, you would need to use renderFile for that. The syntax is slightly different and documentation is scarce (I'm fixing that).
For your case it would be:

var html;
ejs.renderFile('home.ejs', { names: names }, function(err, res){
    if(err){
        console.log(err);
    }
    html=res;
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants