Combine linkTo and action helpers in Ember.js

Ember Link Action addon This is OK for SEO solution! Install addon ember install ember-link-action Usage You can pass closure action as invokeAction param to {{link-to}} component: {{#link-to ‘other-route’ invokeAction=(action ‘testAction’)}} Link to another route {{/link-to}} To pass parameters to action you can use: {{#link-to ‘other-route’ invokeAction=(action ‘testAction’ param1 param2)}} Link to another route {{/link-to}} … Read more

How to format date in meteor template

You may want to create a global helper like: Template.registerHelper(‘formatDate’, function(date) { return moment(date).format(‘MM-DD-YYYY’); }); Then you can use it like: {{#each vname}} {{formatDate date}} {{/each}} This solution depends on moment which is a handy date manipulation library. If you prefer to produce the string without using moment, there are a number of answers for … Read more

Express.js hbs module – register partials from .hbs file

For convenience, registerPartials provides a quick way to load all partials from a specific directory: var hbs = require(‘hbs’); hbs.registerPartials(__dirname + ‘/views/partials’); Partials that are loaded from a directory are named based on their filename, where spaces and hyphens are replaced with an underscore character: template.html -> {{> template}} template 2.html -> {{> template_2}} login … Read more

Handlebars, whitespace control

Following the history from the pull request to add this feature it looks like this is the correct syntax: <h4> {{~#object~}} Surrounding whitespace would be removed. {{/object}} </h4> Result: <h4>Surrounding whitespace would be removed.</h4> There is also this syntax which trims only leading whitespace: <h4> {{~#object}} Only leading whitespace would be removed. {{/object}} </h4> Result: … Read more

Example of using Handlebars lookup helper

Sure, past me! Here’s an example from your future. Suppose you have an object or array obj and a variable field and you want to output the value of obj[field], you would use the lookup helper {{lookup obj field}}. The code defining the helper is simply: function(obj, field) { return obj && obj[field]; }