Skip to content

Commit e8ddc97

Browse files
committed
Rename TemplatePreview to TemplateInline
1 parent 938be54 commit e8ddc97

17 files changed

Lines changed: 75 additions & 68 deletions

File tree

docs/src/content/docs/authoring/blocks/TemplatePreview.mdx renamed to docs/src/content/docs/authoring/blocks/TemplateInline.mdx

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: <TemplatePreview>
2+
title: <TemplateInline>
33
---
44

55
import { Aside } from '@astrojs/starlight/components';
66

7-
The `<TemplatePreview>` block renders a preview of the Boilerplate templates inline, displaying the rendered output directly in your runbook. It uses the Gruntwork Boilerplate template engine to generate content, and optionally saves files to your generated files workspace.
7+
The `<TemplateInline>` block renders a preview of the Boilerplate templates inline, displaying the rendered output directly in your runbook. It uses the Gruntwork Boilerplate template engine to generate content, and optionally saves files to your generated files workspace.
88

99
### Quick example
1010

@@ -24,7 +24,7 @@ variables:
2424
```
2525
</Inputs>
2626
27-
<TemplatePreview inputsId="s3-config" outputPath="s3.tf">
27+
<TemplateInline inputsId="s3-config" outputPath="s3.tf">
2828
```hcl
2929
resource "aws_s3_bucket" "main" {
3030
bucket = "{{ .BucketName }}-{{ .Environment }}"
@@ -35,16 +35,16 @@ resource "aws_s3_bucket" "main" {
3535
}
3636
}
3737
```
38-
</TemplatePreview>
38+
</TemplateInline>
3939
`````
4040

41-
After the user fills out the form and clicks Submit, `<TemplatePreview>` will render the Terraform template with the provided values and display the result inline.
41+
After the user fills out the form and clicks Submit, `<TemplateInline>` will render the Terraform template with the provided values and display the result inline.
4242

4343
TODO: Screenshots
4444

4545
## When to use
4646

47-
Use `<TemplatePreview>` when you want to show users what generated content looks like, or when you want to show generated content without actually creating files in the generated files workspace.
47+
Use `<TemplateInline>` when you want to show users what generated content looks like, or when you want to show generated content without actually creating files in the generated files workspace.
4848

4949
Here are some common use cases:
5050

@@ -58,16 +58,16 @@ Here are some common use cases:
5858
**required**
5959
**type:** `ReactNode`
6060

61-
The template content to render. Write the template as a fenced code block inside the `<TemplatePreview>` tags. The code block should include a language hint (e.g., `hcl`, `yaml`, `dockerfile`) for syntax highlighting.
61+
The template content to render. Write the template 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.
6262

6363
#### Example
6464

6565
`````mdx
66-
<TemplatePreview inputsId="some-config">
66+
<TemplateInline inputsId="some-config">
6767
```txt
6868
Hello, {{ .Name }}. This is inline template content!
6969
```
70-
</TemplatePreview>
70+
</TemplateInline>
7171
`````
7272

7373
### `inputsId`
@@ -109,7 +109,7 @@ variables:
109109
```
110110
</Inputs>
111111
112-
<TemplatePreview inputsId="docker-config" outputPath="Dockerfile">
112+
<TemplateInline inputsId="docker-config" outputPath="Dockerfile">
113113
```dockerfile
114114
FROM node:{{ .NodeVersion }}-alpine
115115

@@ -121,12 +121,12 @@ COPY . .
121121
EXPOSE 3000
122122
CMD ["node", "server.js"]
123123
```
124-
</TemplatePreview>
124+
</TemplateInline>
125125
`````
126126

127127
### Multiple files
128128

129-
You can have multiple `<TemplatePreview>` blocks referencing the same `<Inputs>`:
129+
You can have multiple `<TemplateInline>` blocks referencing the same `<Inputs>`:
130130

131131
`````mdx
132132
<Inputs id="app-config">
@@ -140,20 +140,20 @@ variables:
140140
```
141141
</Inputs>
142142
143-
<TemplatePreview inputsId="app-config" outputPath="config.yaml">
143+
<TemplateInline inputsId="app-config" outputPath="config.yaml">
144144
```yaml
145145
app:
146146
name: {{ .AppName }}
147147
environment: {{ .Environment }}
148148
```
149-
</TemplatePreview>
149+
</TemplateInline>
150150
151-
<TemplatePreview inputsId="app-config" outputPath=".env">
151+
<TemplateInline inputsId="app-config" outputPath=".env">
152152
```bash
153153
APP_NAME={{ .AppName }}
154154
ENVIRONMENT={{ .Environment }}
155155
```
156-
</TemplatePreview>
156+
</TemplateInline>
157157
`````
158158

159159
### Reference multiple Inputs
@@ -182,7 +182,7 @@ variables:
182182
```
183183
</Inputs>
184184
185-
<TemplatePreview inputsId={["global-config", "service-config"]} outputPath="deploy.tf">
185+
<TemplateInline inputsId={["global-config", "service-config"]} outputPath="deploy.tf">
186186
```hcl
187187
resource "aws_ecs_service" "main" {
188188
name = "{{ .ServiceName }}-{{ .Environment }}"
@@ -192,7 +192,7 @@ resource "aws_ecs_service" "main" {
192192
}
193193
}
194194
```
195-
</TemplatePreview>
195+
</TemplateInline>
196196
`````
197197

198198
### With Boilerplate logic
@@ -212,7 +212,7 @@ variables:
212212
```
213213
</Inputs>
214214
215-
<TemplatePreview inputsId="terraform-config" outputPath="main.tf">
215+
<TemplateInline inputsId="terraform-config" outputPath="main.tf">
216216
```hcl
217217
resource "aws_instance" "app" {
218218
ami = "ami-12345678"
@@ -223,7 +223,7 @@ resource "aws_instance" "app" {
223223
{{- end }}
224224
}
225225
```
226-
</TemplatePreview>
226+
</TemplateInline>
227227
`````
228228

229229
## Features
@@ -240,21 +240,21 @@ Rendered content is displayed with syntax highlighting based on the language hin
240240

241241
If template rendering fails (e.g., invalid Boilerplate syntax), an error message is displayed instead of the rendered content.
242242

243-
## TemplatePreview vs BoilerplateInputs
243+
## TemplateInline vs Template
244244

245-
| Feature | `<TemplatePreview>` | `<BoilerplateInputs>` with path |
245+
| Feature | `<TemplateInline>` | `<Template>` with path |
246246
|---------|--------------------|---------------------------------|
247247
| Generates files | Optional (`generateFile={true}`) | Always saves to workspace |
248248
| Template location | Inline only | Can reference directories |
249249
| Use case | Show what will be generated, optionally save | Generate files from external templates |
250250

251251
<Aside type="note">
252-
Use `<TemplatePreview>` when you want to show users what files will look like inline. Add `generateFile={true}` to also save the file to the workspace.
252+
Use `<TemplateInline>` when you want to show users what files will look like inline. Add `generateFile={true}` to also save the file to the workspace.
253253
</Aside>
254254

255255
## Complete example
256256

257-
Here's a complete example showing `<Inputs>` with multiple `<TemplatePreview>` blocks:
257+
Here's a complete example showing `<Inputs>` with multiple `<TemplateInline>` blocks:
258258

259259
`````mdx
260260
<Inputs id="service-config">
@@ -273,7 +273,7 @@ variables:
273273
```
274274
</Inputs>
275275
276-
<TemplatePreview inputsId="service-config" outputPath="docker-compose.yaml">
276+
<TemplateInline inputsId="service-config" outputPath="docker-compose.yaml">
277277
```yaml
278278
version: "3.8"
279279
services:
@@ -284,14 +284,15 @@ services:
284284
environment:
285285
- NODE_ENV={{ .Environment }}
286286
```
287-
</TemplatePreview>
287+
</TemplateInline>
288288
289-
<TemplatePreview inputsId="service-config" outputPath=".env">
289+
<TemplateInline inputsId="service-config" outputPath=".env">
290290
```bash
291291
SERVICE_NAME={{ .ServiceName }}
292292
PORT={{ .Port }}
293293
ENVIRONMENT={{ .Environment }}
294294
```
295-
</TemplatePreview>
295+
</TemplateInline>
296296
`````
297297

298+

docs/src/content/docs/authoring/blocks/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ Blocks are special React components that you can use in your MDX runbooks to add
1414
- [`<Check>`](/authoring/blocks/check)
1515
- [`<Command>`](/authoring/blocks/command)
1616
- [`<Inputs>`](/authoring/blocks/inputs)
17-
- [`<TemplatePreview>`](/authoring/blocks/templatepreview)
17+
- [`<TemplateInline>`](/authoring/blocks/templateinline)
1818

testdata/demo-runbook-2/runbook.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ We just created the `.mise.toml` file. We're going to use this shortly in your n
124124

125125
Here's a preview of the GitHub Actions workflow we'll add to your repo:
126126

127-
<TemplatePreview inputsId="infrastructure-live-root-repo-inputs" outputPath="ci.yml" generateFile={true}>
127+
<TemplateInline inputsId="infrastructure-live-root-repo-inputs" outputPath="ci.yml" generateFile={true}>
128128
```yaml
129129
name: CI
130130
@@ -148,7 +148,7 @@ jobs:
148148
- name: Validate
149149
run: tofu validate
150150
```
151-
</TemplatePreview>
151+
</TemplateInline>
152152

153153
### Create Terragrunt foundations
154154

testdata/demo-runbook-3/runbook.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@ Now let's create a standalone inputs
3030
3131
Now let's render an inline template based on both test1 and test2
3232
33-
<TemplatePreview inputsId="test2">
33+
<TemplateInline inputsId="test2">
3434
```yaml
3535
orgName: {{ .GithubOrgName }}
3636
```
37-
</TemplatePreview>
37+
</TemplateInline>
3838
3939
## Test 4
4040
4141
Now let's render an inline template that pulls from both test1 and test2
4242
43-
<TemplatePreview inputsId={["test1", "test2"]}>
43+
<TemplateInline inputsId={["test1", "test2"]}>
4444
```yaml
4545
orgName: {{ .GithubOrgName }}
4646
orgNamePrefix: {{ .OrgNamePrefix }}
4747
```
48-
</TemplatePreview>
48+
</TemplateInline>
4949
5050
## Test 5
5151

testdata/runbook-with-inline-boilerplate/runbook.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ variables:
4040
4141
Use the form below to configure your deployment:
4242
43-
<TemplatePreview inputsId="test1" outputPath="sample.hcl">
43+
<TemplateInline inputsId="test1" outputPath="sample.hcl">
4444
```hcl
4545
# This template uses manually initialized variables
4646
resource "aws_s3_bucket" "example" {
@@ -52,15 +52,15 @@ resource "aws_s3_bucket" "example" {
5252
}
5353
}
5454
```
55-
</TemplatePreview>
55+
</TemplateInline>
5656

5757
## Boielrplate config 2
5858

5959
<BoilerplateInputs id="test2" templatePath="." />
6060

6161
### Code snippet 2
6262

63-
<TemplatePreview inputsId="test2" outputPath="/a/b.hcl">
63+
<TemplateInline inputsId="test2" outputPath="/a/b.hcl">
6464
```hcl
6565
terraform {
6666
required_version = ">= 1.0"
@@ -87,7 +87,7 @@ locals {
8787
}
8888
}
8989
```
90-
</TemplatePreview>
90+
</TemplateInline>
9191

9292
## Check
9393

@@ -112,7 +112,7 @@ Check: Hit the endpoint (get from the module output!) and make sure it returns H
112112

113113
## Manual variable initialization example
114114

115-
You can also manually initialize variables in a TemplatePreview:
115+
You can also manually initialize variables in a TemplateInline:
116116

117117

118118

web/src/components/MDXContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { AppError } from '@/types/error'
66
// Support MDX components
77
import { Inputs } from '@/components/mdx/Inputs'
88
import { Template } from '@/components/mdx/Template'
9-
import { TemplatePreview } from '@/components/mdx/TemplatePreview'
9+
import { TemplateInline } from '@/components/mdx/TemplateInline'
1010
import { ComponentIdRegistryProvider } from '@/contexts/ComponentIdRegistry'
1111
import { BlockVariablesProvider } from '@/contexts/BlockVariablesContext'
1212
import { Check } from '@/components/mdx/Check'
@@ -213,7 +213,7 @@ const compileMDX = async (content: string): Promise<React.ComponentType> => {
213213
// Form and template components
214214
Inputs,
215215
Template,
216-
TemplatePreview,
216+
TemplateInline,
217217
// Script execution components
218218
Check,
219219
Command,

web/src/components/mdx/Inputs/Inputs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { useComponentIdRegistry } from '@/contexts/ComponentIdRegistry'
1919
*
2020
* The collected variables are published to context so they can be used by:
2121
* - <Template> components (for file generation)
22-
* - <TemplatePreview> components (for inline preview)
22+
* - <TemplateInline> components (for inline preview)
2323
* - <Command> and <Check> components (for script variable substitution)
2424
*
2525
* @param props.id - Unique identifier for this component (required)

web/src/components/mdx/TemplatePreview/TemplatePreview.tsx renamed to web/src/components/mdx/TemplateInline/TemplateInline.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { useFileTree } from '@/hooks/useFileTree'
1111
import { mergeFileTrees } from '@/lib/mergeFileTrees'
1212
import { CodeFile } from '@/components/artifacts/code/CodeFile'
1313

14-
interface TemplatePreviewProps {
14+
interface TemplateInlineProps {
1515
/** ID or array of IDs of Inputs components to get variable values from. When multiple IDs are provided, variables are merged in order (later IDs override earlier ones). */
1616
inputsId?: string | string[]
1717
/** Output path prefix for generated files */
@@ -23,18 +23,18 @@ interface TemplatePreviewProps {
2323
}
2424

2525
/**
26-
* TemplatePreview renders inline template content with variable substitution.
26+
* TemplateInline renders inline template content with variable substitution.
2727
* It displays the rendered output as code blocks (preview only, no file generation).
2828
*
2929
* Variables are sourced from Inputs components referenced by inputsId.
3030
* When multiple inputsIds are provided, variables and configs are merged (later IDs override earlier).
3131
*/
32-
function TemplatePreview({
32+
function TemplateInline({
3333
inputsId,
3434
outputPath,
3535
generateFile = false,
3636
children
37-
}: TemplatePreviewProps) {
37+
}: TemplateInlineProps) {
3838
// Render state
3939
const [renderState, setRenderState] = useState<'waiting' | 'rendered'>('waiting');
4040
const [renderData, setRenderData] = useState<{ renderedFiles: Record<string, File> } | null>(null);
@@ -142,7 +142,7 @@ function TemplatePreview({
142142

143143
useEffect(() => {
144144
// Check if we have all required variables
145-
// Note that TemplatePreview is a pure consumer of variables, so it only has importedVarValues
145+
// Note that TemplateInline is a pure consumer of variables, so it only has importedVarValues
146146
if (!hasAllRequiredVariables(importedVarValues)) {
147147
return;
148148
}
@@ -178,7 +178,7 @@ function TemplatePreview({
178178
}
179179
})
180180
.catch(err => {
181-
console.error(`[TemplatePreview][${outputPath}] Render failed:`, err);
181+
console.error(`[TemplateInline][${outputPath}] Render failed:`, err);
182182
});
183183
}, delay);
184184
}, [importedVarValues, hasAllRequiredVariables, outputPath, renderTemplate, setFileTree, generateFile]);
@@ -222,6 +222,7 @@ function TemplatePreview({
222222
}
223223

224224
// Set displayName for React DevTools and component detection
225-
TemplatePreview.displayName = 'TemplatePreview';
225+
TemplateInline.displayName = 'TemplateInline';
226+
227+
export default TemplateInline;
226228

227-
export default TemplatePreview;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { default as TemplateInline } from './TemplateInline'
2+
3+

0 commit comments

Comments
 (0)