Note that there are some explanatory texts on larger screens.

plurals
  1. POsame helper for different template
    primarykey
    data
    text
    <p>as the <a href="https://github.com/meteor/meteor/wiki/Handlebars" rel="nofollow noreferrer">official meteor wiki about handlebars</a> said:</p> <blockquote> <p>The only way to make a helper visible to multiple templates is to assign the same function to each one, or to declare a global helper.</p> </blockquote> <p>I am using the <a href="https://github.com/SachaG/Telescope" rel="nofollow noreferrer">telescope</a> to build an app and the problem is the value of "member since" in user-profile is missing like the follow image.<br> <img src="https://i.stack.imgur.com/6VFo7.png" alt="enter image description here"><br> as the source code in /client/views/users/user_profile.js <code>Template.user_profile.createdAtFormatted = Template.user_item.createdAtFormatted;</code> does not work well.</p> <p>and here is the helper in /client/views/users/user_item.js <code>Template.user_item</code></p> <pre><code>Template.user_item.helpers({ createdAtFormatted: function(){ return this.createdAt ? moment(this.createdAt).fromNow() : '–'; }) </code></pre> <p>,when I change the code in /client/views/users/user_profile.js like this:</p> <pre><code>Template.user_profile.createdAtFormatted = function() { return this.createdAt ? moment(this.createdAt).fromNow() : '–'; } </code></pre> <p>or make a Global helpers like this </p> <pre><code>Handlebars.registerHelper("createdAtFormatted", function(){ return this.createdAt ? moment(this.createdAt).fromNow() : '–'; }); </code></pre> <p>then, everything is ok like this<br> <img src="https://i.stack.imgur.com/FUtEd.png" alt="enter image description here"> </p> <p>all I wonder is why the assignment <code>Template.user_profile.createdAtFormatted = Template.user_item.createdAtFormatted;</code> did not work as the way I or the author wish?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload