meteor-blaze

How to write Iron-router nested template?

别来无恙 提交于 2019-12-10 16:33:32
问题 I have 2 templates: 1) mainLayout.html -> general layout which must be used by all pages. (e.g. page title, navbar, footer) Router.configure({ layoutTemplate: 'mainLayout' }) <template name="mainLayout"> {{> header}} <div class="container-fluid"> {{> yield}} </div> </template> 2) specialLayout.html -> custom layout which is inheriting main-layout.html but with additional template (e.g. side/tab menu) How should I define specialLayout ? Note that specialLayout should have the title, navbar,

Meteor how to save templates in mongo

梦想的初衷 提交于 2019-12-10 11:17:59
问题 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

#each string in an array with blaze in Meteor

江枫思渺然 提交于 2019-12-09 16:41:11
问题 I have an array of usernames that I am rendering in a list like so: {{#each contacts}} <div class="name">{{this}}</div> {{/each}} This works just fine, but then I try to get the username from an event: 'click .name': function(e,t){ console.log(this) } I get this frustrating object String {0: "c", 1: "h", 2: "a", 3: "r", 4: "l", 5: "i", 6: "e", length: 7, [[PrimitiveValue]]: "charlie"} which makes it very challenging to do string comparisons with. Any ideas why this is even a problem or what

event.target is undefined in events

点点圈 提交于 2019-12-09 08:39:55
问题 How can one use each input values in events ? Hope my below code will explain you well. HTML: <template name="UpdateAge"> {{#each Name}} <div data-action="showPrompt"> <div> Some content </div> <div> <div> Some content </div> </div> <div> Name : {{name}} Age : <input type="text" name="age" value="{{age}}"/> //I need to access age values in event </div> </div> {{/each}} <template> JS: Template.UpdateAge.events({ 'click [data-action="showPrompt"]': function (event, template) { console.log(event

How can I dynamically render HTML using Meteor Spacebars templates?

折月煮酒 提交于 2019-12-09 05:44:24
问题 So let's say I'm storing <div>{{name}}</div> and <div>{{age}}</div> in my database. Then I want to take the first HTML string and render it in a template - {{> template1}} which just renders the first string with the {{name}} handlebar in it. Then I want to give that newly generated template/html data, so that it can fill in the handlebar with the actual name from the database, so that we would get <div>John</div> . I've tried doing <template name="firstTemplate"> {{#with dataGetter}} {{>

Meteor.js - Calling a template helper within template rendered

不打扰是莪最后的温柔 提交于 2019-12-08 07:11:04
问题 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

What is a recommended way to get data into your meteor template from the front-end for a famous surface?

纵然是瞬间 提交于 2019-12-08 06:32:09
问题 I've been following along with the book Discover Meteor from https://www.discovermeteor.com/ and I have built the tutorial project called 'Microscope' This uses iron-router and Meteor templating system to render out the front-end. I want to redo this project using famo.us for the front-end but I am unclear on how I to do so. I am aware of a package called famono. mrt add famono. Using this package I can integrate famo.us and draw surface to the screen in a meteor project. It also allows you

Meteor Helper Check equality

自作多情 提交于 2019-12-08 05:28:52
问题 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

template.find() vs document.querySelector vs jquery vs template.$ performance in Meteor

99封情书 提交于 2019-12-07 19:14:56
问题 I know that using template.find() or template.$ to search the DOM in Meteor is faster than searching all the DOM with document.querySelector() or jQuery. But I don't know how much faster. I imagine it would be directly related to the number of DOM nodes of the app but I don't know if that's the case or if there's any other optimization/degradation in Meteor that makes this assumption not so proportional. Does anyone know about a performance test/result on this? 回答1: template is not equal to

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

六月ゝ 毕业季﹏ 提交于 2019-12-07 06:33:35
问题 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> {{