Commit e739bcc
committed
fix(inertia-sails): ensure locals are accessible via locals.xxx in EJS templates
Sails's default EJS renderer creates an `options.locals` object for internal
helpers (blocks, layout, partial). EJS wraps templates in `with(data) { ... }`,
which causes `locals` inside the template to resolve to `data.locals` (the
Sails-created object) rather than the function parameter containing the actual
view data. This made `<%= locals.title %>` always return undefined.
Fix by pre-populating `data.locals` with user-provided locals so they survive
the `with` scoping.
Closes #1881 parent 0065895 commit e739bcc
1 file changed
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
36 | 45 | | |
37 | 46 | | |
0 commit comments