-
-
Notifications
You must be signed in to change notification settings - Fork 65
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
[3.X - Express] Support res.render() #279
Comments
@enzoclock thank you! I appreciate this suggestion, but I think it's best to keep the Eta API as minimal as possible. However, I do like your solution. Maybe you could submit a PR to add that to the Eta documentation here? |
var w = express()
var eta = new Eta({ 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 above
function buildEtaEngine(): (
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 {
const fileContent = eta.readFile(path)
const renderedTemplate = eta.renderString(fileContent, opts)
callback(null, renderedTemplate)
} catch (error) {
callback(error as Error)
}
}
} for some reason the path doesn't work if I don't add |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: