Custom Templates
Creating your own templates allows you to standardize the way your team starts new projects.
Creating a Module
- Create Directory: Add a new folder under
templates/(e.g.,templates/frontend/modules/my-cool-feature). - Add Files: Put your boilerplate code in this directory. Use
.hbsextension for Handlebars processing. - Define Manifest: Create a
module.jsonfile.
Handlebars Variables
Trix provides several variables to your templates:
{{projectName}}: The name of the new project.{{typescript}}: Boolean indicating if TypeScript is enabled.{{framework}}: The name of the selected framework.{{packageManager}}: The tool being used (npm,pnpm, etc.).
Example Template
// src/config.ts
export const config = {
name: "{{projectName}}",
version: "1.0.0",
{{#if typescript}}
type: "typescript"
{{else}}
type: "javascript"
{{/if}}
};
Integrating with the CLI
To make your new template available in the prompts, you'll need to update the relevant prompt logic in src/prompts/.