Skip to content

<TemplateInline>

The <TemplateInline> block renders Boilerplate templates directly in your runbook, displaying the rendered output inline. Unlike <Template>, which loads templates from a directory, <TemplateInline> lets you write template content directly in your runbook file.

<Inputs id="greeting">
```yaml
variables:
- name: Name
type: string
default: World
```
</Inputs>
<TemplateInline inputsId="greeting" outputPath="hello.txt">
```txt
Hello, {{ .Name }}!
```
</TemplateInline>

TemplateInline and Template both render Boilerplate templates, but they serve different purposes:

Feature<TemplateInline><Template>
Template sourceInline in runbookDirectory with boilerplate.yml
Form renderedNo (uses Inputs)Yes, from boilerplate.yml
File generationOptional (generateFile={true})Always saves to workspace
Use caseShow preview of single files inlineGenerate files from template directories

Use <TemplateInline> when you want to show users what generated content looks like inline, or for quick single-file templates. Use <Template> when you have a full Boilerplate template directory with multiple files and a boilerplate.yml configuration.

  • [Inline template content] - The template content to render, written as a fenced code block inside the <TemplateInline> tags. The code block should include a language hint (e.g., hcl, yaml, dockerfile) for syntax highlighting.
  • inputsId (string | string[]) - ID of the Inputs block(s) to get variable values from. When multiple IDs are provided as an array, variables are merged in order (later IDs override earlier ones). If not provided, the template renders without variable substitution.
  • outputPath (string) - File path to display for the rendered output (e.g., config.yaml). This appears as the filename in the code block header.
  • generateFile (boolean) - Whether to add the rendered file to the file tree. When false (the default), the template is preview-only and displays inline. Set to true to also save the rendered file to the workspace.

There are several ways to provide variables to a TemplateInline.

Reference a separate Inputs block to get variable values:

<Inputs id="docker-config">
```yaml
variables:
- name: AppName
type: string
- name: NodeVersion
type: string
default: "18"
```
</Inputs>
<TemplateInline inputsId="docker-config" outputPath="Dockerfile">
```dockerfile
FROM node:{{ .NodeVersion }}-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]
```
</TemplateInline>

You can reference multiple Inputs blocks by passing an array of IDs. Variables are merged in order, with later IDs overriding earlier ones:

<Inputs id="global-config">
```yaml
variables:
- name: Environment
type: enum
options: [dev, staging, prod]
default: dev
```
</Inputs>
<Inputs id="service-config">
```yaml
variables:
- name: ServiceName
type: string
- name: Port
type: int
default: 8080
```
</Inputs>
<TemplateInline inputsId={["global-config", "service-config"]} outputPath="deploy.tf">
```hcl
resource "aws_ecs_service" "main" {
name = "{{ .ServiceName }}-{{ .Environment }}"
load_balancer {
container_port = {{ .Port }}
}
}
```
</TemplateInline>

In this example, the template has access to variables from both Inputs blocks.

You can have multiple <TemplateInline> blocks referencing the same <Inputs>:

<Inputs id="app-config">
```yaml
variables:
- name: AppName
type: string
- name: Environment
type: enum
options: [dev, prod]
```
</Inputs>
<TemplateInline inputsId="app-config" outputPath="config.yaml">
```yaml
app:
name: {{ .AppName }}
environment: {{ .Environment }}
```
</TemplateInline>
<TemplateInline inputsId="app-config" outputPath=".env">
```bash
APP_NAME={{ .AppName }}
ENVIRONMENT={{ .Environment }}
```
</TemplateInline>

You can use full Boilerplate template syntax including conditionals and loops:

<Inputs id="terraform-config">
```yaml
variables:
- name: Environment
type: enum
options: [dev, prod]
- name: EnableMonitoring
type: bool
default: false
```
</Inputs>
<TemplateInline inputsId="terraform-config" outputPath="main.tf">
```hcl
resource "aws_instance" "app" {
ami = "ami-12345678"
instance_type = "{{ if eq .Environment "prod" }}t3.large{{ else }}t3.micro{{ end }}"
{{- if .EnableMonitoring }}
monitoring = true
{{- end }}
}
```
</TemplateInline>

For full details on template syntax, see Boilerplate Template Syntax.

By default, <TemplateInline> is preview-only—it shows the rendered output but doesn’t save files. To also save the rendered content to the generated files workspace, set generateFile={true}:

<Inputs id="config">
```yaml
variables:
- name: ProjectName
type: string
```
</Inputs>
<TemplateInline
inputsId="config"
outputPath="README.md"
generateFile={true}
>
```markdown
# {{ .ProjectName }}
Welcome to {{ .ProjectName }}!
```
</TemplateInline>

Here’s a complete example showing <Inputs> with multiple <TemplateInline> blocks:

# Configure Your Docker Service
Enter your service configuration:
<Inputs id="service-config">
```yaml
variables:
- name: ServiceName
type: string
description: Name of your service
validations: "required"
- name: Port
type: int
description: Port to expose
default: 8080
- name: Environment
type: enum
description: Deployment environment
options: [dev, staging, prod]
default: dev
```
</Inputs>
Here's what your Docker Compose file will look like:
<TemplateInline inputsId="service-config" outputPath="docker-compose.yaml" generateFile={true}>
```yaml
version: "3.8"
services:
{{ .ServiceName }}:
build: .
ports:
- "{{ .Port }}:{{ .Port }}"
environment:
- NODE_ENV={{ .Environment }}
```
</TemplateInline>
And your environment file:
<TemplateInline inputsId="service-config" outputPath=".env" generateFile={true}>
```bash
SERVICE_NAME={{ .ServiceName }}
PORT={{ .Port }}
ENVIRONMENT={{ .Environment }}
```
</TemplateInline>