<BoilerplateTemplate>
The <BoilerplateTemplate>
block renders Boilerplate templates inline or allows you to specify templates inline in your runbook. Like <BoilerplateInputs>
, it uses the Boilerplate engine to generate files, but displays the rendered file directly in the markdown.
Overview
Section titled “Overview”Both <BoilerplateInputs>
and <BoilerplateTemplate>
use the Boilerplate engine to generate files. The key differences are:
<BoilerplateInputs>
: Generates files and saves them to your workspace (persisted), can reference template directories<BoilerplateTemplate>
: Generates files, displays content inline, allows inline template specification
Use <BoilerplateTemplate>
when you want to:
- Show users a preview of what will be generated
- Display generated configuration inline
- Debug template rendering
- Generate content for display rather than file creation
Basic Usage
Section titled “Basic Usage”<BoilerplateInputs id="config">```yamlvariables: - name: ServiceName type: string description: Name of the service default: my-service - name: Port type: int description: Port number default: 8080```</BoilerplateInputs>
<BoilerplateTemplate boilerplateInputsId="config">```yaml# config.yamlservice: name: {{ .ServiceName }} port: {{ .Port }} enabled: true```</BoilerplateTemplate>
Required Props
Section titled “Required Props”boilerplateInputsId
(string) - ID of the BoilerplateInputs block to get variables from
Optional Props
Section titled “Optional Props”outputPath
(string) - Optional subdirectory name for the generated files in the preview- Security: Must be a relative path without
..
(e.g.,prod
,environments/staging
) - Will be created as a subdirectory within the CLI-configured output path
- Absolute paths and directory traversal attempts are blocked for security
- Security: Must be a relative path without
children
(ReactNode) - Inline template content to render
How It Works
Section titled “How It Works”- User fills out the BoilerplateInputs form
- BoilerplateTemplate automatically uses the Boilerplate engine to generate files with the current variable values
- Files are generated to temporary directories, read for display, then immediately cleaned up
- Generated content is displayed in the UI with syntax highlighting
- No files are persisted to your workspace (only shown in the UI)
Examples
Section titled “Examples”Single File Template
Section titled “Single File Template”<BoilerplateInputs id="docker-config">```yamlvariables: - name: AppName type: string - name: NodeVersion type: string default: "18"```</BoilerplateInputs>
<BoilerplateTemplate boilerplateInputsId="docker-config">```dockerfileFROM node:{{ .NodeVersion }}-alpine
WORKDIR /app
COPY package*.json ./RUN npm install
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]```</BoilerplateTemplate>
Multiple Files
Section titled “Multiple Files”You can have multiple BoilerplateTemplate blocks referencing the same BoilerplateInputs:
<BoilerplateInputs id="app-config">```yamlvariables: - name: AppName type: string - name: Environment type: enum options: [dev, prod]```</BoilerplateInputs>
### Application Configuration
<BoilerplateTemplate boilerplateInputsId="app-config" outputPath="config.yaml">```yamlapp: name: {{ .AppName }} environment: {{ .Environment }}```</BoilerplateTemplate>
### Environment Variables
<BoilerplateTemplate boilerplateInputsId="app-config" outputPath=".env">```bashAPP_NAME={{ .AppName }}ENVIRONMENT={{ .Environment }}```</BoilerplateTemplate>
With Boilerplate Logic
Section titled “With Boilerplate Logic”You can use full Boilerplate template syntax:
<BoilerplateInputs id="terraform-config">```yamlvariables: - name: Environment type: enum options: [dev, prod] - name: InstanceType type: string default: t3.micro - name: EnableMonitoring type: bool default: false```</BoilerplateInputs>
<BoilerplateTemplate boilerplateInputsId="terraform-config">```hclresource "aws_instance" "app" { ami = "ami-12345678" instance_type = "{{ .InstanceType }}"
tags = { Name = "app-{{ .Environment }}" Environment = "{{ .Environment }}" }
{{- if .EnableMonitoring }} monitoring = true {{- end }}}```</BoilerplateTemplate>
Features
Section titled “Features”Auto-Rendering
Section titled “Auto-Rendering”The template automatically re-renders whenever the user changes values in the linked BoilerplateInputs form (with debouncing for performance).
Syntax Highlighting
Section titled “Syntax Highlighting”Rendered content is displayed with appropriate syntax highlighting based on the file extension or language hint.
File Tree View
Section titled “File Tree View”When multiple BoilerplateTemplate blocks reference the same BoilerplateInputs, they’re organized in a file tree view.
Error Handling
Section titled “Error Handling”If template rendering fails (e.g., invalid Boilerplate syntax), an error message is displayed.
Advanced Usage
Section titled “Advanced Usage”Directory Structure
Section titled “Directory Structure”You can organize templates in a directory structure using the outputPath prop:
<BoilerplateTemplate boilerplateInputsId="config" outputPath="terraform/main.tf">...</BoilerplateTemplate>
<BoilerplateTemplate boilerplateInputsId="config" outputPath="terraform/variables.tf">...</BoilerplateTemplate>
<BoilerplateTemplate boilerplateInputsId="config" outputPath="scripts/deploy.sh">...</BoilerplateTemplate>
Conditional Templates
Section titled “Conditional Templates”Use Boilerplate’s conditional logic:
<BoilerplateTemplate boilerplateInputsId="config">```hcl{{- if eq .Environment "prod" }}# Production configurationresource "aws_instance" "app" { instance_type = "t3.large" monitoring = true}{{- else }}# Development configurationresource "aws_instance" "app" { instance_type = "t3.micro" monitoring = false}{{- end }}```</BoilerplateTemplate>
Limitations
Section titled “Limitations”- Templates must be inline (cannot reference template directories like BoilerplateInputs can)
- Generated files are not persisted to your workspace (only displayed in the UI)
- Cannot include other template files (no
{{ template "file.txt" }}
support) - Best for simple, single-file templates or small sets of templates