[ ] Regression
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
@Render annotation argument is just a string. I can not dynamically change template depends on application state.
I think it would be much better to resign from @Render annotation in favour of directly rendering a page. We can derive patterns from other technology stacks and possibly controllers should have a method to return in example this.render('template.hbs', { message }) instead of just an object with render annotation. There could be dedicated controller like MVCController (name to be discussed) with a render method.
It's possible in other technology stacks and others framework to dynamically render the page. @Render annotation looks not fully functional.
Nest version: 6.0.0
For Tooling issues:
- Node version: 10.15.3
- Platform: Mac
Others:
Hey, cze艣膰,
Try to choose template dynamically based on value returned from a service.
You can inject response object using @Res() decorator and then use res.render() conditionally. Perhaps, it's worth adding to the documentation :)
Cze艣膰 ;)
Yeah, you're right. I didn't think about it. It'd be useful to add such information to the documentation 馃槃. I can do it in a free time 馃憤
That would be awesome :) Let's track this issue here https://github.com/nestjs/docs.nestjs.com/issues/290 (PRs open). Thanks!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Hey, cze艣膰,
You can inject response object using
@Res()decorator and then useres.render()conditionally. Perhaps, it's worth adding to the documentation :)