diff --git a/assets/views/layouts/svelte_layout.html b/assets/views/layouts/svelte_layout.html
index cb58f1d..caf13b9 100644
--- a/assets/views/layouts/svelte_layout.html
+++ b/assets/views/layouts/svelte_layout.html
@@ -6,20 +6,19 @@
diff --git a/src/frontend/SvelteViewEngine.ts b/src/frontend/SvelteViewEngine.ts
index 7114085..786701f 100644
--- a/src/frontend/SvelteViewEngine.ts
+++ b/src/frontend/SvelteViewEngine.ts
@@ -221,7 +221,7 @@ export default class SvelteViewEngine extends ViewEngine {
logger.info(canonicalName + ' > ', 'Replacing backend calls');
// Skip replace if there is no swaf export
- if (!code.match(/export[ \n]+let[ \n]+locals[ \n]*=[ \n]*{[ \n]*}/)) {
+ if (!code.match(/import[ \n]+\{[ \n]*locals[ \n]*\}[ \n]+from[ \n]+["'](\.\.\/)+ts\/stores\.js["']/)) {
return {
backendCalls: [],
code: code,
@@ -296,7 +296,12 @@ export default class SvelteViewEngine extends ViewEngine {
// Load locals into locals store
const localsModulePath = "../../build/ts/stores.js";
const localsModule = await import(localsModulePath);
- localsModule.locals.set(ViewEngine.getGlobals());
+ const locals = ViewEngine.getGlobals();
+ localsModule.locals.set((key: string, args: string) => {
+ return locals[args ?
+ `'${key}', \`${args}\``
+ : `'${key}'`];
+ });
// Load module and render
return requireFromString(svelteSsr.js.code, file + nanoid() + '.js').default.render();