-
-
Notifications
You must be signed in to change notification settings - Fork 428
feat(template): support for arbitrary replacements #1037
Conversation
Thanks @vilarfg, works great for SSR rendering of JSS styles into the template 👍 |
…late-replacements
.replace('%sapper.head%', () => `<noscript id='sapper-head-start'></noscript>${head}<noscript id='sapper-head-end'></noscript>`) | ||
.replace('%sapper.styles%', () => styles); | ||
const body = replace(template(), { | ||
...res.replacers, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here as my other comment, actually.
) { | ||
for (const key in replacers) { | ||
if (replacers.hasOwnProperty(key)) { | ||
template = template.replace(new RegExp(`%sapper.${key}%`, 'g'), replacers[key] as any); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have replacers less coupled to the %sapper.key%
pattern? It would be flexible to let replacers define their own patterns to replace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…late-replacements
Thanks for putting together this PR! Sapper never had a good method of handling configuration, which made it difficult to know how to integrate this feature. However, that's been addressed in SvelteKit by adding a |
Fixes #1036