spacebars

Since Meteor upgrade to 0.8.0, Template “rendered” callback is not fired when Session variable dependancy changes

天大地大妈咪最大 提交于 2019-12-22 09:56:26
问题 I'm stuck with a problem since I upgraded to 0.8.0. The Template rendered is not being fired anymore (except the first time). I followed the recommendations as in: https://github.com/avital/meteor-ui-new-rendered-callback/blob/master/new2/client/each.js This didn't helped, and so I finally made this small piece of code (by modifying the new2 example). The main difference is that the update is triggered by a Session variable change instead of a DB change. This perfectly shows the problem, as

How can I use if condition on the meteor template?

左心房为你撑大大i 提交于 2019-12-22 04:12:37
问题 I want to use an if condition in a Meteor Blaze template. Let's say you have a helper users on the Users collection you want to iterate through tasks and if the username is admin, use a "red" style: <ul> {{#each users}} <li {{#if(name==admin)}}class="red"{{/if}}>{{name}}</li> {{/each}} </ul> 回答1: Meteor uses Spacebars, a variant of Handlebars, which are "logicless" templates. You need to define a Template helper, then use it in the {{#if}} . Template.foo.helpers({ isAdmin: function (name) {

How to access global variables in Meteor template without using a helper?

纵然是瞬间 提交于 2019-12-21 12:35:30
问题 I have all my image files served from a different domain, and I put that host name as a variable into Meteor.settings. Then, how can I access this variable within a Meteor template? For example, in this template, what's the best practice to replace img.example.com with a variable defined in Meteor.settings or some other global variables? I don't think it's a good idea to pass it to every template by using helpers. <template name="products"> {{#each items}} <img src="http://img.example.com/{

How to execute a callback after an #each is done?

浪尽此生 提交于 2019-12-19 18:23:22
问题 I'm having trouble with a callback after the #each has finished. I have a template named "content": <template name="content"> {{#if Template.subscriptionsReady}} {{#each currentData}} <div data-cid="{{this._id}}"></div> {{/each}} {{else}} Loading... {{/if}} </template> At first I wait for a subscription, when this is available, I iterate through my Collection with {{#each}} and append the div . What I need is a sort of callback for when the for-each loop is done (in other words DOM ready).

Multiple yield in Meteor.js application template

戏子无情 提交于 2019-12-18 16:58:29
问题 I have one general {{>yield}} for iron-router in a layout file which renders my pages, which are templates. In one of my pages, I have a side menu and according to the selection in this menu, I want to load different templates related to this page in this page. How can I achieve this? 回答1: I have done a similar thing using iron-router's layout template option. Say I want to create a home view with multiple views/templates inside of this home view that will change. First I would declare my

Multiple yield in Meteor.js application template

梦想与她 提交于 2019-12-18 16:58:19
问题 I have one general {{>yield}} for iron-router in a layout file which renders my pages, which are templates. In one of my pages, I have a side menu and according to the selection in this menu, I want to load different templates related to this page in this page. How can I achieve this? 回答1: I have done a similar thing using iron-router's layout template option. Say I want to create a home view with multiple views/templates inside of this home view that will change. First I would declare my

How can I get the index of an array in a Meteor template each loop?

元气小坏坏 提交于 2019-12-17 03:18:08
问题 Say I have an object, someObject: { foo: "apple", myArray: ["abc", "def"] } And a template helper that looks like this (and works fine): getArray: function(){ var self = this; self.myArray = self.myArray || []; return self.myArray; } How should I construct the html to get the array index? I've tried: <template name="someObject"> // takes someObject as data {{#each getArray}} <div class="item" data-value="{{WHAT GOES HERE?}}">{{this}}</div> {{/each}} </template> In which case this successfully

How can I get the index of an array in a Meteor template each loop?

倾然丶 夕夏残阳落幕 提交于 2019-12-17 03:17:45
问题 Say I have an object, someObject: { foo: "apple", myArray: ["abc", "def"] } And a template helper that looks like this (and works fine): getArray: function(){ var self = this; self.myArray = self.myArray || []; return self.myArray; } How should I construct the html to get the array index? I've tried: <template name="someObject"> // takes someObject as data {{#each getArray}} <div class="item" data-value="{{WHAT GOES HERE?}}">{{this}}</div> {{/each}} </template> In which case this successfully

How do I iterate over an unknown object in a Meteor Spacebars template?

大憨熊 提交于 2019-12-13 06:39:23
问题 So I have a Meteor Collection. Each object/document in that collection can have an unknown structure. That is to say, I don't know the name of each property, nor how many there are, until runtime. Essentially, each object in the collection is created from arbitrary data people provide via my front-end page (via CSV upload, which works fine). So I don't initialize the collection when Meteor starts. Now I'd like to create a table in my HTML page, that renders the collection, but without me pre

How do I convert Handlebars isEq helper to Spacebars in Meteor?

岁酱吖の 提交于 2019-12-12 19:29:23
问题 I've had in my Meteor project handlebar helper: Handlebars.registerHelper('isEq', function(v1, v2, options){ if(v1 === v2){ return options.fn(this); }else{ return options.inverse(this); } }); But after update to 0.8 and switch from handlebars to spacebars it is not working anymore - I've found in other stackoverflow topic that now I should change Handlebars.registerHelper to UI.registerHelper but it is still not working - anyone know how to implement this properly for spacebars? 回答1: You want