Variable System

Give templates shape to adapt to different scenarios

Variables let the same engineering pattern adapt to different scenarios and constraints, making templates flexible.

Variable Types

AgileBuilder supports these variable types:

string - String

For project names, package names, port numbers, etc.:

{
  "name": "projectName",
  "type": "string",
  "description": "Project name",
  "required": true,
  "default": "my-app",
  "pattern": "^[a-z][a-z0-9-]*$"
}

boolean - Boolean

For enabling/disabling feature modules:

{
  "name": "useTypeScript",
  "type": "boolean",
  "description": "Use TypeScript",
  "default": true
}

select - Single Select

Choose one from predefined options:

{
  "name": "packageManager",
  "type": "select",
  "description": "Package manager",
  "options": ["npm", "pnpm", "yarn"],
  "default": "pnpm"
}

multiselect - Multi Select

Select multiple options:

{
  "name": "features",
  "type": "multiselect",
  "description": "Select features",
  "options": ["eslint", "prettier", "husky", "jest"],
  "default": ["eslint", "prettier"]
}

Using Variables in Templates

Content Replacement

Using Handlebars syntax:

{
  "name": "{{projectName}}",
  "version": "1.0.0"
}

Conditional Rendering

{{#if useTypeScript}}
  "typescript": "^5.0.0",
{{/if}}

Loop Rendering

{{#each features}}
  "{{this}}": "latest",
{{/each}}

Next Steps