meteor-blaze

Meteor Helper Check equality

☆樱花仙子☆ 提交于 2019-12-06 15:12:25
Is there a way to check the value of a string in meteor helper? Lets say i have this helper Template.example.helpers({ typeOfVideo:function(videoType){ var videoLink = GS.Gems.Collections.Gems.findOne({_id:this._id}).videoLink; if(videoLink.match(/youtube\.com/)){ return "youtube"; }else if(videoLink.match(/vimeo\.com/)){ return "vimeo"; }else{ return "undefined" } } }) Now i want to check if the video is equal to Youtube, Vimeo or undefined, i could do by returning true/false, but since there are more i want to know what type of video im dealing with Already try with {{#if typeOfVideo=youtube

Meteor.js - Calling a template helper within template rendered

时光怂恿深爱的人放手 提交于 2019-12-06 15:08:23
I'm using Meteor 1.0. I have a Template.*name*.rendered function that makes a number of calculations. At the end of the calculations, I would like the output to make its way into a Template.*name*.helpers so I can use it in the corresponding html page. Here's a simplified version of the code: Template.myTemplate.rendered = function () { var x = Math.random(); Template.otherTemplate.helpers({ randomNum: x }); } When I call {{randomNum}} in otherTemplate , nothing happens. I have also tried putting the Template.*name*.helpers outside of Template.*name*.rendered , in which case, I get the error:

Can I pass the this._id value from one template helper to another with Meteor?

青春壹個敷衍的年華 提交于 2019-12-06 11:54:27
问题 I have the following templates (.html) with their respected managers (.js files): adminManageCategories adminAddCategory adminUpdateCategory Consider the following: <template name="adminManageCategories"> {{#each category}} <div class="clickme">{{title}}</div> {{/each}} {{> adminUpdateCategory}} </template> Notice the {{> adminUpdateCategory}} is outside of the iteration. This is also a form, and I want to keep it on the same page. And admin_manage_categories.js Template.adminManageCategories

Meteor leaderboard app on node-webkit

纵然是瞬间 提交于 2019-12-06 11:27:42
问题 I am trying to get the meteor leaderboard app to run on Node-Webkit. I have demeteorized it and compressed it to a .nw file but when I drop it in. I get errors: Invalid Package There is no 'package.json' in the package, please make sure the 'package.json' is in the root of the package. I have read on various thread but nothing clear yet. It seems like the demeteorized app needs to be restructured. Also need to figure out how to run the server [Locally/DDP]. Edited: P.S. I am using the

Meteor how to save templates in mongo

不问归期 提交于 2019-12-06 10:41:52
I want to give my users the possibility to create document templates (contracts, emails, etc.) The best option I figured out would be to store these document templates in mongo (maybe I'm wrong...) I've been searching for a couple of hours now but I can't figure out how to render these document template with their data context. Example: Template stored in Mongo: "Dear {{firstname}}" data context: {firstname: "Tom"} On Tom's website, He should read: "Dear Tom" How can I do this? EDIT After some researches, I discovered a package called spacebars-compiler that brings the option to compile to the

Meteor.js: how to swap partial templates in and out of the main page

孤者浪人 提交于 2019-12-06 07:27:49
Just starting with meteor. Looking for a way to have a single "main page", which would contain an area, in which different partial templates could be swapped in and out, at a click of a Next/Previous buttons. I understand how to include partial templates statically by using {{> step_1_Template}} syntax. What I need, is to have the Next/Previous buttons permanently on the main page, and, when the Next button is clicked - remove the {{> step_1_Template}} and insert the {{> step_2_Template}}. How is this done? My knee-jerk reaction is that you should just use iron-router . However, that may only

Accessing template helper dictionary in Meteor event handler

若如初见. 提交于 2019-12-06 03:45:41
问题 In Meteor, I'm sending two objects from my db to a template: Template.myTemplate.helpers({ helper1: function() { var object1 = this; // data context set in iron:router...path is context dependent // modify some values in object1 return this; }, helper2: function() { return Collection2.find({_id: this.object2_id}); } }); This template also has an event handler to modify the two objects above. I am trying to access helper1 and helper2 from above, but if I call the data context of the template,

How can I repeat a block N times in a Meteor Spacebars template?

我是研究僧i 提交于 2019-12-06 03:40:20
问题 I have this block of code in a Spacebars template: 1. <select class="form-group"> {{#each choices}} <option>{{this}}</option> {{/each}} </select> I would like to repeat this N times incrementing the number each time like so: 1. <select class="form-group"> {{#each choices}} <option>{{this}}</option> {{/each}} </select> 2. <select class="form-group"> {{#each choices}} <option>{{this}}</option> {{/each}} </select> 3. <select class="form-group"> {{#each choices}} <option>{{this}}</option> {{/each

Meteor takes time to know if there's a {{currentUser}} or not

戏子无情 提交于 2019-12-05 11:19:56
I've a few code that I want to run only when there's noUser and a few when there's a currentUser . All these are inside the navigation template. Like so... {{#if currentUser}} <li class="nav"><a href="{{pathFor 'create'}}">Post</a> </li> <li class="nav"><a>Ola, {{thisUser}}!</a> </li> <li class="nav"><a href="#" id="logout">Log Out</a> </li> {{/if}} {{#if noUser}} <li class="nav"><a href="{{pathFor 'signup'}}">Sign Up</a> </li> <li class="nav"><a href="{{pathFor 'login'}}">Login</a> </li> {{/if}} So the problem is that when there's a currentUser (i.e, I'm logged in) and I refresh the page, the

ng-repeat + filter like feature in Meteor Blaze/Spacebars

北城余情 提交于 2019-12-05 01:19:21
问题 I am from AngularJS background, recently start learning Meteor. In AngularJS, I may have something like: <div ng-repeat="person in persons | filter:search"> <h4>{{person.name}}</h4> <b>{{person.age}}</b> </div> search object can be bound (2-way bound) to HTML textbox. Whenever the textbox changed, the filter will be automatically updated. How to do so in Meteor? 回答1: I am not familiar with AngularJS, but here is an example of how you would accomplish this with Meteor. This example shows a