reactdto3
reactdto3

Reputation: 21

JavaScript NestJS: get param in Render() method

I have 2 hbs files ie: test.template.de.hbs and test.template.en.hbs

  @Get('/test/:locale')
  @Render(`/templates/test.template.${@Param() locale}.hbs`)
  root(): any {
    return { test: 1 };
  }

I would like to render the file depending on what I give in params, but I'm not sure how I can save it and whether it can be done.

Upvotes: 1

Views: 407

Answers (1)

Jay McDoniel
Jay McDoniel

Reputation: 70490

@Render() is a decorator, so it doesn't have access to other decorators like @Param(). What you could do instead is inject @Res() and call res.render() so that you have access to the @Param() value

Upvotes: 1

Related Questions