Skip to content

build: preserve handlebars placeholders in code snippets#284

Merged
petermuessig merged 1 commit into
mainfrom
fix/escape-handlebars-in-code-snippets
Jun 1, 2026
Merged

build: preserve handlebars placeholders in code snippets#284
petermuessig merged 1 commit into
mainfrom
fix/escape-handlebars-in-code-snippets

Conversation

@petermuessig
Copy link
Copy Markdown
Contributor

Problem

The published READMEs under dist/<tutorial>/build/<step>/README.md are rendered by GitHub Pages via Jekyll/Liquid. Liquid uses the same {{ ... }} / {% ... %} syntax that several tutorial code snippets need to display verbatim — most notably the UI5 i18n placeholders {{appTitle}} and {{appDescription}} in manifest.json examples (e.g. walkthrough/steps/10). Without escaping, Liquid silently replaces them with empty strings on the published page.

Fix

Add an escapeCodeBlocks helper in tools/builder/prepare-gh-pages.js and call it from rewriteLinks() before each README is written to dist/:

  • Fenced code blocks (`````` or ~~~) get a surrounding `{% raw %}` / `{% endraw %}` pair.
  • Inline backtick spans get the same treatment only when they actually contain {{ or {%, to keep the output minimal.

The downloadable source copies under dist/<tutorial>/steps/ (which are zipped and offered for download) are not touched, so unzipped tutorial projects keep their original UI5 i18n placeholders intact.

Verification

After running npm run build:

GitHub Pages renders the markdown via Jekyll/Liquid, which uses the
same {{ ... }} / {% ... %} syntax that several tutorial code snippets
need to display verbatim (e.g. {{appTitle}} and {{appDescription}} in
manifest.json examples). Without escaping, Liquid replaces them with
empty strings on the published page.

Wrap fenced code blocks and inline code spans with {% raw %} ... {% endraw %}
in rewriteLinks() before writing the README.md files to dist/. Inline
spans are only wrapped when they actually contain {{ or {% to keep the
output minimal. The downloadable source copies under dist/<tutorial>/steps
are not touched, so the unzipped projects keep the original UI5 i18n
placeholders intact.
@petermuessig petermuessig enabled auto-merge (squash) June 1, 2026 11:15
@petermuessig
Copy link
Copy Markdown
Contributor Author

@jnsttl - once you reviewed the change it will be merged

@jnsttl jnsttl self-requested a review June 1, 2026 14:18
@petermuessig petermuessig merged commit e09b3fc into main Jun 1, 2026
3 checks passed
@petermuessig petermuessig deleted the fix/escape-handlebars-in-code-snippets branch June 1, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants