1

As my ROOT_URL differs in Dev and Prod environments I am rtying to use the Meteor.settings functionality to set my href values correctly.

Because links are used all over the application, it seemed a natural candidate for a helper on the body template. It is defined like so:

  Template.body.helpers({
     rootURL: Meteor.settings.public.root_url
  })

and in the template it is used like so:

<li class="{{guessesActive}}">
    <a href="{{rootURL}}guesses" class="waves-effect waves-light">Guesses
        <span class="sr-only">(current)</span>
    </a>
</li>

But the value of Meteor.settings.public.root_url is not appended to the anchor.

Micha Roon
  • 3,957
  • 2
  • 30
  • 48

2 Answers2

1

I think you just need to add as a registered helper instead of appending to the body. Template.registerHelper('rootURL', function() {...}); Then return the appropriate value. Meteor docs have more on registerHelper.

terrafirma9
  • 362
  • 2
  • 15
0

It turns out I misunderstood the body template. I thought it was meant to be accessible for all. It runs out this is not the case. It is meant to allow using helpers directly in the <body> tag.

To set global helpers, define a global variable called Helpers and assign it an object with the functions and variables you want accessible.

As explained in this post https://stackoverflow.com/a/28837834/763962

Community
  • 1
  • 1
Micha Roon
  • 3,957
  • 2
  • 30
  • 48