Skip to content

Commit ff8a85e

Browse files
potchRich-Harris
andauthored
feat: add %sveltekit.version% placeholder for template interpolation (#12132)
* feat: Add %sveltekit.version% placeholder for template interpolation * docs * changeset * oops * escape --------- Co-authored-by: Rich Harris <[email protected]>
1 parent 8d38e5a commit ff8a85e

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

.changeset/twelve-cows-hear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': minor
3+
---
4+
5+
feat: add `%sveltekit.version%` to `app.html`

documentation/docs/10-getting-started/30-project-structure.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ The `src` directory contains the meat of your project. Everything except `src/ro
5252
- `error.html` is the page that is rendered when everything else fails. It can contain the following placeholders:
5353
- `%sveltekit.status%` — the HTTP status
5454
- `%sveltekit.error.message%` — the error message
55+
- `%sveltekit.version%` — the deployment version, which can be specified with the [`version`](configuration#version) configuration
5556
- `hooks.client.js` contains your client [hooks](hooks)
5657
- `hooks.server.js` contains your server [hooks](hooks)
5758
- `service-worker.js` contains your [service worker](service-workers)

packages/kit/src/core/sync/write_server.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { load_error_page, load_template } from '../config/index.js';
77
import { runtime_directory } from '../utils.js';
88
import { isSvelte5Plus, write_if_changed } from './utils.js';
99
import colors from 'kleur';
10+
import { escape_html } from '../../utils/escape.js';
1011

1112
/**
1213
* @param {{
@@ -54,6 +55,7 @@ export const options = {
5455
.replace('%sveltekit.body%', '" + body + "')
5556
.replace(/%sveltekit\.assets%/g, '" + assets + "')
5657
.replace(/%sveltekit\.nonce%/g, '" + nonce + "')
58+
.replace(/%sveltekit\.version%/g, escape_html(config.kit.version.name))
5759
.replace(
5860
/%sveltekit\.env\.([^%]+)%/g,
5961
(_match, capture) => `" + (env[${s(capture)}] ?? "") + "`

0 commit comments

Comments
 (0)