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
I want to know if it is possible, and if not, feasible, to create one template for injecting multiple (let's say node) dependencies to the package.json with one template, but each of them may be coupled to a different skip_if. For instance:
Whereas the controller template scaffolds something like follows:
// controller.ejs.t
---
to: app/controller/<%= name %>.controller.ts
---
import { Body, Controller, Post, Get } from '@nestjs/common'
<% if(locals.healthcheck) {-%>import { ApiResponse, ApiExcludeEndpoint } from '@nestjs/swagger'<% } -%>
@Controller()
export class Controller {
constructor() {}
# THIS IS ONLY AVAILABLE IF healthcheck GETS PASSED AS PROPERTY
<% if (locals.healthcheck) { -%>
@ApiExcludeEndpoint()
@Get(`${BASE_URL}${HEALTH_CHECK}`)
@ApiResponse({ status: 200, description: 'Proxy service is up and running.' })
async health(): Promise<void> {}
<% } -%>
@Post()
async proxyRequest(@Body() request: ProxyRequestDto) {
// no op
}
}
We can see in the controller example above, that some dependencies will only be necessary to import and therefore maintained in the package.json if the optional code block gets included in the file creation.
Currently, the only possibility, at least as it seems to me, would be to create one template for each dependency:
This would be fine for this scenario, however, it would scale linear with increasing complexity of your templates.
It would be nice to have something like aggregations of Frontmatter templates like this:
That would require especial parsing and allowing frontmatter in the middle may be complicated.
How about adding a modify or update action that gets the existing file content and returns the updated content?
That could be achieved in at least two ways, by having a variable contents in the context and a normal ejs body, or by having the template export a function transform(contents: string, context: {}): string as a named or as the default export
I want to know if it is possible, and if not, feasible, to create one template for injecting multiple (let's say node) dependencies to the package.json with one template, but each of them may be coupled to a different
skip_if
. For instance:Whereas the controller template scaffolds something like follows:
We can see in the controller example above, that some dependencies will only be necessary to import and therefore maintained in the
package.json
if the optional code block gets included in the file creation.Currently, the only possibility, at least as it seems to me, would be to create one template for each dependency:
Which leads us to the following template setup
This would be fine for this scenario, however, it would scale linear with increasing complexity of your templates.
It would be nice to have something like aggregations of Frontmatter templates like this:
As far as I know, nothing comparable is possible currently. Can you help me out with this?
Kind regards!
The text was updated successfully, but these errors were encountered: