Skip to content

v1.2.2

Choose a tag to compare

@DominusKelvin DominusKelvin released this 02 Mar 17:47

inertia-sails v1.3.2

Bug Fixes

Locals now accessible via locals.xxx in EJS templates (#188)

Fixed a bug where <%= locals.title %> in EJS templates always returned undefined, causing fallback defaults to render instead of dynamic values passed via the locals API (sails.inertia.local(), sails.inertia.localGlobally(), or action-level return { locals: {...} }).

Before: Dynamic locals were silently ignored — the rendered HTML always showed fallback values.

<!-- Always rendered "My App" regardless of what locals were set -->
<title><%= locals.title || 'My App' %></title>

After: Dynamic locals correctly render in the EJS template.

<!-- Now correctly renders the dynamic value from the action -->
<title><%= locals.title || 'My App' %></title>

Root cause: Sails's default EJS renderer creates an internal options.locals object for template helpers (blocks, layout, partial). EJS compiles templates with with(data) { ... }, which caused locals inside the template to resolve to this internal object rather than the actual view data. The fix pre-populates data.locals with user-provided values so they survive the with scoping.

Full Changelog

  • fix(inertia-sails): ensure locals are accessible via locals.xxx in EJS templates (#189)

Full Changelog: v1.2.1...v1.2.2