Skip to content

Commit e3315bc

Browse files
committed
fix: standardize Liquid syntax references in documentation
- Updated various documentation files to replace HTML-encoded Liquid syntax with the standard format `{{ ... }}` for consistency and clarity. - Ensured that all instances of `context.data` and related examples reflect the correct syntax, improving readability and preventing rendering issues.
1 parent 1196adb commit e3315bc

8 files changed

Lines changed: 28 additions & 22 deletions

File tree

.github/scripts/docs/fix-docs.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,13 @@ for dir in code-based configuration-based; do
7070
# Replace %} with %}
7171
line="${line//%\}/%}}"
7272
echo "$line" >> "$temp_file"
73+
# Check for inline code with Liquid syntax (surrounded by single backticks)
74+
elif [[ "$line" =~ \`[^\`]*(\{\{|\{%).*\` ]]; then
75+
# Replace single backticks containing Liquid syntax with double backticks
76+
line=$(echo "$line" | sed -E 's/`([^`]*(\{\{|\{%).*?)`/``\1``/g')
77+
echo "$line" >> "$temp_file"
7378
else
74-
# Outside code blocks, keep as is
79+
# Outside code blocks and no inline code, keep as is
7580
echo "$line" >> "$temp_file"
7681
fi
7782
done < "$file"

.github/scripts/docs/fix-schema-links.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ find "$BASE_DIR" -type f -name "*.md" | grep -v "node_modules" | while read file
3232
if [[ "$file" == *"/schemas/"* ]]; then
3333
if grep -q "^---" "$file" && ! grep -q "parent:" "$file" && [[ "$file" != *"/schemas/index.md" ]]; then
3434
sed "${SED_INPLACE[@]}" '/^layout:/a\
35-
parent: SCHEMA REFERENCE' "$file"
35+
parent: Schema Reference' "$file"
3636
fi
3737

38-
# Make case consistent in existing parent references (Schema Reference -> SCHEMA REFERENCE)
38+
# Make case consistent in existing parent references (Schema Reference -> Schema Reference)
3939
if grep -q "parent: Schema Reference" "$file"; then
40-
sed "${SED_INPLACE[@]}" 's/parent: Schema Reference/parent: SCHEMA REFERENCE/g' "$file"
40+
sed "${SED_INPLACE[@]}" 's/parent: Schema Reference/parent: Schema Reference/g' "$file"
4141
fi
4242

4343
# Fix common schema reference patterns
@@ -141,7 +141,7 @@ if [ ! -f "./SCHEMA_REFERENCE.md" ]; then
141141
cat > "./SCHEMA_REFERENCE.md" << EOF
142142
---
143143
layout: default
144-
title: SCHEMA REFERENCE
144+
title: Schema Reference
145145
nav_order: 5
146146
has_children: true
147147
permalink: /schemas/
@@ -179,7 +179,7 @@ if [ -f "./schemas/README.md" ] && [ ! -f "./schemas/index.md" ]; then
179179
sed "${SED_INPLACE[@]}" '/^---/,/^---/d' "./schemas/index.md"
180180

181181
# Add new front matter
182-
front_matter="---\nlayout: default\ntitle: SCHEMA REFERENCE\nnav_order: 5\nhas_children: true\npermalink: /schemas/\n---\n\n"
182+
front_matter="---\nlayout: default\ntitle: Schema Reference\nnav_order: 5\nhas_children: true\npermalink: /schemas/\n---\n\n"
183183
sed "${SED_INPLACE[@]}" "1s/^/$front_matter/" "./schemas/index.md"
184184

185185
echo "✅ Created schemas/index.md with proper front matter"

.github/scripts/docs/process-docs.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ else
134134
# Create a completely new file with proper front matter
135135
if [ "$is_core" = true ]; then
136136
# Core schema - visible in navigation
137-
echo -e "---\nlayout: default\ntitle: \"$title\"\nparent: SCHEMA REFERENCE\n---\n\n$content" > "$file"
137+
echo -e "---\nlayout: default\ntitle: \"$title\"\nparent: Schema Reference\n---\n\n$content" > "$file"
138138
else
139139
# Non-core schema - hidden from navigation
140-
echo -e "---\nlayout: default\ntitle: \"$title\"\nparent: SCHEMA REFERENCE\nnav_exclude: true\n---\n\n$content" > "$file"
140+
echo -e "---\nlayout: default\ntitle: \"$title\"\nparent: Schema Reference\nnav_exclude: true\n---\n\n$content" > "$file"
141141
fi
142142
done
143143

@@ -167,10 +167,10 @@ else
167167

168168
if [ "$is_core" = true ]; then
169169
# Core schema - visible in navigation
170-
sed "${SED_INPLACE[@]}" "1s/^/---\nlayout: default\ntitle: \"$title\"\nparent: SCHEMA REFERENCE\n---\n\n/" "$file"
170+
sed "${SED_INPLACE[@]}" "1s/^/---\nlayout: default\ntitle: \"$title\"\nparent: Schema Reference\n---\n\n/" "$file"
171171
else
172172
# Non-core schema - hidden from navigation
173-
sed "${SED_INPLACE[@]}" "1s/^/---\nlayout: default\ntitle: \"$title\"\nparent: SCHEMA REFERENCE\nnav_exclude: true\n---\n\n/" "$file"
173+
sed "${SED_INPLACE[@]}" "1s/^/---\nlayout: default\ntitle: \"$title\"\nparent: Schema Reference\nnav_exclude: true\n---\n\n/" "$file"
174174
fi
175175
continue
176176
fi
@@ -189,10 +189,10 @@ else
189189
# Add proper front matter with correct line breaks
190190
if [ "$is_core" = true ]; then
191191
# Core schema - visible in navigation
192-
sed "${SED_INPLACE[@]}" "1s/^/---\nlayout: default\ntitle: \"$title\"\nparent: SCHEMA REFERENCE\n---\n\n/" "$file"
192+
sed "${SED_INPLACE[@]}" "1s/^/---\nlayout: default\ntitle: \"$title\"\nparent: Schema Reference\n---\n\n/" "$file"
193193
else
194194
# Non-core schema - hidden from navigation
195-
sed "${SED_INPLACE[@]}" "1s/^/---\nlayout: default\ntitle: \"$title\"\nparent: SCHEMA REFERENCE\nnav_exclude: true\n---\n\n/" "$file"
195+
sed "${SED_INPLACE[@]}" "1s/^/---\nlayout: default\ntitle: \"$title\"\nparent: Schema Reference\nnav_exclude: true\n---\n\n/" "$file"
196196
fi
197197
continue
198198
fi
@@ -247,7 +247,7 @@ nav_exclude: true' "$file"
247247
cat > "$BASE_DIR/temp_schema_ref.md" << EOF
248248
---
249249
layout: default
250-
title: SCHEMA REFERENCE
250+
title: Schema Reference
251251
nav_order: 5
252252
has_children: true
253253
permalink: /schemas/

docs/features/code-based/PAGE_VIEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ The main template layout is `govuk-frontend`'s `template.njk` file, this also ne
1919

2020
## Using page views with data from your own API
2121

22-
Page templates have access to `&#123;&#123; context.data &#125;&#125;`, which is an attribute made available when a page event is triggered. It represents the entire response body from your API. To learn more about this, [see our guidance on page events](../configuration-based/PAGE_EVENTS.md).
22+
Page templates have access to `{{ context.data }}`, which is an attribute made available when a page event is triggered. It represents the entire response body from your API. To learn more about this, [see our guidance on page events](../configuration-based/PAGE_EVENTS.md).

docs/features/configuration-based/PAGE_EVENTS.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Page events are a configuration-based way of triggering an action on an event tr
1111

1212
DXT's forms engine is a frontend service, which should remain as lightweight as possible with business logic being implemented in a backend/BFF API. Using page events, DXT can call your API and use the tailored response downstream, such a page templates to display the response value.
1313

14-
The downstream API response becomes available under the `&#123;&#123; context.data &#125;&#125;` view model attribute for view templates, so it can be used when rendering a page. This attribute is directly accessible by our [page templates](./../configuration-based/PAGE_TEMPLATES.md) feature and our Nunjucks-based views.
14+
The downstream API response becomes available under the `{{ context.data }}` view model attribute for view templates, so it can be used when rendering a page. This attribute is directly accessible by our [page templates](./../configuration-based/PAGE_TEMPLATES.md) feature and our Nunjucks-based views.
1515

1616
## Architecture
1717

@@ -115,10 +115,11 @@ Your API response:
115115
Page template:
116116

117117
```jinja2
118-
&#123;% if context.data.awardedGrantValue %&#125;
119-
<p class="govuk-body">Congratulations. You are likely to receive up to £&#123;&#123; context.data.awardedGrantValue &#125;&#125;.</p>
120-
&#123;% endif %&#125;
118+
{% if context.data.awardedGrantValue %}
119+
<p class="govuk-body">Congratulations. You are likely to receive up to £{{ context.data.awardedGrantValue }}.</p>
120+
{% endif %}
121121
<p class="govuk-body">You have not been awarded any funding for this application.</p>
122+
{% endif %}
122123
```
123124

124125
Results in:

docs/features/configuration-based/PAGE_TEMPLATES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ The following elements support [LiquidJS templates](https://liquidjs.com/):
6161
## Template data
6262

6363
The data the templates are evaluated against is the raw answers the user has provided up to the page they're currently on.
64-
For example, given a YesNoField component called `TKsWbP`, the template `&#123;&#123; TKsWbP &#125;&#125;` would render "true" or "false" depending on how the user answered the question.
64+
For example, given a YesNoField component called `TKsWbP`, the template `{{ TKsWbP }}` would render "true" or "false" depending on how the user answered the question.
6565

6666
The current FormContext is also available as `context` in the templates. This allows access to the full data including the path the user has taken in their journey and any miscellaneous data returned from `Page event`s in `context.data`.
6767

@@ -158,4 +158,4 @@ Whilst DXT offers some out of the box filters, teams using the plugin have the c
158158

159159
## Using page templates with data from your own API
160160

161-
Page templates have access to`&#123;&#123; context.data &#125;&#125;` , which is an attribute made available when a page event is triggered. It represents the entire response body from your API. To learn more about this, [see our guidance on page events](./PAGE_EVENTS.md).
161+
Page templates have access to``{{ context.data }}` , which is an attribute made available when a page event is triggered. It represents the entire response body from your API. To learn more about this, [see our guidance on page events](./PAGE_EVENTS.md).

scripts/generate-schema-docs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export function createIndexFile(schemaFiles) {
177177

178178
const content = `---
179179
layout: default
180-
title: SCHEMA REFERENCE
180+
title: Schema Reference
181181
nav_order: 5
182182
has_children: true
183183
permalink: /schemas/

src/server/plugins/engine/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The following elements support [LiquidJS templates](https://liquidjs.com/):
1818
### Template data
1919

2020
The data the templates are evaluated against is the raw answers the user has provided up to the page they're currently on.
21-
For example, given a YesNoField component called `TKsWbP`, the template `&#123;&#123; TKsWbP &#125;&#125;` would render "true" or "false" depending on how the user answered the question.
21+
For example, given a YesNoField component called `TKsWbP`, the template `{{ TKsWbP }}` would render "true" or "false" depending on how the user answered the question.
2222

2323
The current FormContext is also available as `context` in the templates. This allows access to the full data including the path the user has taken in their journey and any miscellaneous data returned from `Page event`s in `context.data`.
2424

0 commit comments

Comments
 (0)