You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello 👋 Before anything, thank you for this nice template engine :)
Context
Unless I misread the documentation, it seems that V3 doesn't support the good'old Express res.render() anymore.
During setup, it is not possible to app.engine("eta", eta.render) to define eta as an express view engine.
My poor solution
Here is my walk around
constexpress=require("express");const{ Eta }=require("eta");// Create appconstapp=express();// Setup etaconsteta=newEta({views: "./views"});app.engine("eta",buildEtaEngine());app.set("view engine","eta");// Home routeapp.get("/",(req,res)=>{res.render("home",{message: "Hello John"});});// Start serverapp.listen(3000,()=>{console.log(`Listening at http://localhost:${3000}`);});functionbuildEtaEngine(){return(path,opts,callback)=>{try{constfileContent=eta.readFile(path);constrendered=eta.renderString(fileContent,opts);callback(null,rendered);}catch(error){callback(error);};};}
Question
Any reason for it not being supported anymore ?
Would it be interesting to add a eta.getExpressEngine() method or equivalent so the required setup to use the res.render() syntax with Express remains simple ?
Note
I'm not so familiar with open source contributions, let me know if anything is unclear
The text was updated successfully, but these errors were encountered:
varw=express()vareta=newEta({views: path.join(__dirname,"views"),cache: false})w.engine("eta",buildEtaEngine())w.set("view engine","eta")w.set("views",eta.config.views)// idk why need add this, even though the config is already there abovefunctionbuildEtaEngine(): (path: string,opts: any,callback: (error: Error|null,renderedTemplate?: string)=>void)=>void{return(path: string,opts: any,callback: (error: Error|null,renderedTemplate?: string)=>void)=>{try{constfileContent=eta.readFile(path)constrenderedTemplate=eta.renderString(fileContent,opts)callback(null,renderedTemplate)}catch(error){callback(errorasError)}}}
for some reason the path doesn't work if I don't add w.set("views",eta.config.views) or maybe views: path.join(__dirname, "views") is never read?
Hello 👋 Before anything, thank you for this nice template engine :)
Context
Unless I misread the documentation, it seems that V3 doesn't support the good'old Express
res.render()
anymore.During setup, it is not possible to
app.engine("eta", eta.render)
to define eta as an express view engine.My poor solution
Here is my walk around
Question
Any reason for it not being supported anymore ?
Would it be interesting to add a
eta.getExpressEngine()
method or equivalent so the required setup to use theres.render()
syntax with Express remains simple ?Note
I'm not so familiar with open source contributions, let me know if anything is unclear
The text was updated successfully, but these errors were encountered: