locals not accessible within partials
See original GitHub issueMy setup looks something like the following:
var hbs = handlebars.create({
extname: '.hbs'
});
app.locals['static-server'] = 'https://' + config.services.assets.hostname;
app.set('views', app.path('views'));
app.engine('hbs', hbs.engine);
app.set('view engine', 'hbs');
The static-server
local works properly within views, but whenever it is used within a partial, the variable is always undefined. Is this a bug, or do I have something configured incorrectly?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:14
Top Results From Across the Web
Rails partial locals not working - Stack Overflow
Its not a good practice to pass new instance variable as local to a partial you can build the answer and then pass...
Read more >Partials - Sails.js
Partials only inherit locals that are available to the view, partial, or layout where they're called as a whole, but this <li> relies...
Read more >ActionView::PartialRenderer - Rails API
The current object being rendered, as well as the object_counter, will be available as local variables inside the layout template under the same...
Read more >Don't use instance variables in partials - Andy Croll
Instance variables defined in controllers are magically available in view templates. Inferred template names. A global namespace of helpers.
Read more >Can't access Site variables inside nested partial - HUGO
It might be really simple to solve it but everything I tried failed. I have a nested partial, and I would like to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
While in a for each loop, {{@root.yourLocalsDataKey}} may help
Confirming I experienced the same issue, unable to access a
{{user}}
(res.locals.user) inside an{{#each array as |item|}}
@WeiGrand 's solution worked for.
{{@root.user.name}}