Reputation: 493
Given that I have something like this set in javascript:
window.App.url.login = '/account/login';
How can I pass that variable into a Meteor Spacebars template? e.g. something like this:
{{> Anchor href=window.App.url.login class="btn-success" label="Login"}}
Upvotes: 2
Views: 197
Reputation: 22696
You need to register a global helper for this :
Template.registerHelper("appUrlLogin",function(){
return App.url.login;
});
Then use it like this :
{{> Anchor href=appUrlLogin class="btn-success" label="Login"}}
Alternatively, you could declare the helper on the template directly :
HTML
<template name="myTemplate">
{{> Anchor href=appUrlLogin class="btn-success" label="Login"}}
</template>
JS
Template.myTemplate.helpers({
appUrlLogin:function(){
return App.url.login;
}
});
Upvotes: 2