FAQ Database Discussion Community


Does Handlebars require jQuery

javascript,jquery,handlebars.js
I'm trying to build a Handlebars app using only JavaScript. I've noticed in there documentation, they initialize using: var source = $("#entry-template").html(); Is this step required or is there a way around it using only native Javascript?...

Show Action via iron:router, template isn't passed data from a collection.findOne method

javascript,meteor,handlebars.js,iron-router
I can't get a the 'show' page of an instance of a model to display its data. Here's the template that won't show its data: <template name="priority"> <h1>Priority: {{title}}</h1> </template> It's very simple in and of itself, yet I can't get title to display. Iron:router does the job of directing...

Template without application.hbs as root?

ember.js,handlebars.js,ember-cli
I've got an Ember-Cli App and would like to create an admin-interface for my application which looks nothing like the page set up in application.hbs. How do I make the admin-interface independent from that one?...

Handlebars render only some elements

javascript,ember.js,handlebars.js
I have the following handlebars template: <script type="text/x-handlebars" data-template-name="index"> {{log model}} <button {{action 'getSuggestion'}}>Get suggestion</button> {{log suggestion}} {{#if suggestion}} <p>There is a suggestion</p> {{else}} <p>NO suggestion</p> {{/if}} <ul> {{#each item in model}} <li>{{item}}</li> {{/each}} </ul> </script> Currently, the two log work as expected, but the button between them is not...

How to show / hide html elements in Handlebars using conditional statement

javascript,jquery,templates,handlebars.js
I have the following in my handlebars tag: {{#editmode mode}} <div class="form-group login-input"> <i class="fa fa-key overlay"></i> <input type="password" class="form-control text-input" name="password" placeholder="Password" value="{{password}}"> </div> <div class="form-group login-input"> <i class="fa fa-key overlay"></i> <input type="password" class="form-control text-input" name="password_confirmation" value="{{password}}"> </div> {{/editmode}} and I have the following...

emberjs add code on the fly, after template render

ember.js,handlebars.js,htmlbars
In emberjs, you can add code to your template file: {{input type="text" value=color}} the template then renders. But the question is, how can you add this dynamically after the template renders? For example, I want to add a button, to generate new input fields (colors), and the user can continue...

Adding “” to a certain word using handlebars.js

javascript,handlebars.js,handlebars,html-escape
I am using handlebars for JavaScript templating. I want to add around the word "success". I would hopefully want to escape any other html or scripts in the text.

The refreshed AJAX content hidden due to a CSS property

javascript,jquery,ajax,rest,handlebars.js
I have an image. On clicking that image I get a pop-up. The contents inside the pop-up are generated by AJAX. I am using handlebars for templating. Since the pop-up should be hidden initially, I have set it's property to display:none and I am using toggle to show it on...

Handlebars Each Helper scope is changes property

ember.js,handlebars.js
Hi I am using EmberJS in my application and this is my Application-Template and and Application Controller I have a property in controller called isEditAble ,But I have an issue If i used to check this property in outside of each helper , this will execute fine. But if i...

Express 4 register handlebars

javascript,node.js,handlebars.js
I'm trying to run the Handlebars example with Node.js. However, I'm having trouble registering Handlebars. I keep on getting the error Error: callback function required at line 7. var express = require('express'); var app = express(); var port = process.env.PORT || 8888; var router = express.Router(); app.set('view engine', 'html'); app.engine('html',...

Ember Nested Routes and rendering models

javascript,ember.js,routes,handlebars.js,ember-router
I have an invoice application generator and i want to show the invoices with all his transactions in 2 different ways, at the moment i can only do it in 1 way ( Edit Link) On Edit link where i can see all my invoices and transactions together ( it...

Handlebars js - cannot access parent object properties from loop / partial

javascript,handlebars.js
I have the following data object: And with this i am using the following Loop with no problem Templates.Links = [ "<ul>", "{{#each data}}", "<li>", "<div class='flex-item-button'>", "<div class='info noicon'>", "<span class='name'>{{{URL}}}</span>", "<span class='meta'>{{URL}}</span>", "</div>", "<div>", "<span class='expand expand-item-details'><i class='fa fa-sort-down'></i></span>", "</div>", "<div class='additional-info'>", "</div>",...

How iterate through two array in a object using Template helpers in Meteor.js

javascript,json,meteor,handlebars.js,this
My HTML resembles this <template name="stop"> {{#each thumb}} <tr> <td class="image" ><img src="{{this.data}}"></td> <td> <center style="float:right; margin-bottom: 25%;"> <h2> Do you like this product? </h2> <h2>{{this.text}}</h2></center> </td> </tr> {{/each}} </template> And this template refers to my template helper which look like this Template.stop.helpers( { 'thumb': function(data) { console.log(z); return tweetImages.findOne()...

Handlebars - How to access template data in “each” scope?

javascript,handlebars.js,each
I use pre-compiled Handlebars templates. I have the following code: <div id="{{ns}}paymentMethodsTabs"> {{#each paymentMethods}} <button id="{{ns}}{{paymentCardCode}}">{{paymentCardCode}}</button> {{/each}} </div> In the first div, the ns template data is available and set. But inside the each paymentMethods scope, I can't access it, I tried <button id="{{../ns}}{{paymentCardCode}}">{{paymentCardCode}}</button> But it doesn't work either. (the...

Ember Handlebars helper options.inverse undefined is not a function

javascript,ember.js,handlebars.js
So I have a template and I need to show/hide some text based on a return value from a method. I searched and noticed one should use handlebars helpers in order to achieve this. So I added a resetPassword helper inside the controller. The options.fn(this) part works. The options.inverse(this) doesn't....

Passing variables into Handlebars template when rendering Marionette/Backbone View

backbone.js,handlebars.js,marionette
I'm using Handlebars with Backbone and Marionette. I'm compiling my Handlebars templates and storing them in an object that can be referenced by the view definitions. I'm using a LayoutView and regions to display the various items I need in the UI. What I want to do is pass (boolean)...

How to find all the posts with a specific tag in Ghost and iterate over them?

javascript,templates,handlebars.js,ghost-blog,ghost
I'm currently working on a Ghost blog (Ghost is a Wordpress "successor" that is based on Node.js and other various packages/libraries on that platform), but I'm wondering how I might be able to grab all the posts that have a certain tag in Ghost/Handlebars.js. The problem is that Ghost's contexts...

Override Ember application.hbs template

javascript,ember.js,handlebars.js,ember-cli,handlebars
I have an Ember JS application with 99% of it's resources on the root level, which the user has to be logged in to access. All those resources, with the exception of /login, have the same template. /login, however, has an entirely different template (no nav bar, etc). What's the...

Backbone Collection only fetched after executing alert

node.js,backbone.js,express,handlebars.js,jade
Hey I am new to backbone and Handlebars and something strange is happening with my code that I cannot figure out. Basically my node app queries mongo for some data which is then used by backbone and handlebars to relay the data to the user. When I try to relay...

Handlebars compile error

jquery,handlebars.js
I use handlebars to generate a tableview template like this: Template <div id="incidentTableView"> <script id="incidentTemplate" type="text/x-handlebars-template"> <table class="table"> <thead> <th>Latitude</th> <th>Longitude</th> </thead> <tbody> {{#incidents}} <tr> <td>{{Latitude}}</td> <td>{{Longitude}}</td> </tr> {{/incidents}} </tbody> </table> </script> </div> JavaScript $(document).ready(function () {...

Inserting template code below code in Handlebars layout.hbs

javascript,express,tags,handlebars.js,region
I am working with an Express Handlebars project and have a template foo.hbs and it has some javascript I want to insert below the script tags in layout.hbs: <!DOCTYPE html> <html> <head> <title>{{title}}</title> <link rel='stylesheet' href='/stylesheets/style.css' /> </head> <body> {{{body}}} <script type="text/javascript" src="../bower_components/jquery/dist/jquery.js"></script> <script type="text/javascript"...

HandlebarsJS break loop

javascript,xml,handlebars.js
I'm using handelBarsJS to convert JSON to XML . I have this example i'm working on : I have a list "Output" : "output":[ { "name":"Name1", "URI":"Link1", "Ref":"ref1" }, { "name":"Name2", "URI":"Link2", "Ref":"ref2" }, { "name":"Name3", "URI":"Link3" }, { "name":"Name4", "URI":"Link4" } ], and I have this XML template <!--...

Setting Sails js view extension doesn't work

javascript,node.js,handlebars.js,sails.js
I'm using sails 0.10.5 with handlebars. I would like all my handlebars templates to use the extension .hbs instead of .handlebars. I read in the sails documentation that you can set an extension property in config/views to change the file extension that sails will look for when rendering views. http://sailsjs.org/#!/documentation/reference/sails.config/sails.config.views.html...

Double quotes being added to precompiled Ember templates

ember.js,handlebars.js
Here is the template in question: <nav class="navbar navbar-default navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand"> My Company...

Placing handlebar script inside div in ember

html,css,ember.js,handlebars.js
I'm trying to put handlebar scripts inside the left column, but I can't seem to put those inside the div. I must be doing this wrong--this question might be silly, but I am a beginner and have been struggling with it, so your answer would be much appreciated! <div id="map-canvas"></div>...

sortable list in emberjs

ember.js,ember-data,handlebars.js
i have loaded a list from server into handlebar. when the list order changes, i need to send the sorted order back to the server. to make a list sortable, i have used jquery-ui.js. when i change the list order by dragging and dropping the list, visually the list order...

Displaying Bookshelf.js model in hbs view

express,handlebars.js,bookshelf.js
I'm new to Bookshelf.js and hbs and would appreciate your help with the following: I want to pre-fill a handlebars.js view form with data from a Bookshelf.js model. hbs won't let me use the Bookshelf get method to get the desired attribute value: e.g. {{user.get(age)}} I converted the model to...

Dynamically render template without reloading page

javascript,flask,handlebars.js
Just started making a Flask app to make a simple Wizard. For now I have just two "Steps", each with its own HTML templated file; Jinja is the templating language. The first pass at this makes it so that on "Next" and "Previous" it routes to a new page. Simple...

User Permission - Display edit in view (express, handlebars)

node.js,express,authorization,handlebars.js
At the moment I have user profiles that are rendered using Handlbars as such: exports.profile = function(req, res) { User.findOne({username: req.params.username}).exec(function(err, user){ res.render('profile/view', { user: req.user, name: user.name, username: user.username }); }); }; On the rendered template at profile/view I would like to display an edit button if the user...

Handlebars: return hash from helper

javascript,backbone.js,coffeescript,handlebars.js,handlebars
Can i return hash from Handlebars helper? I tried this: In my view: initialize: -> super this.hash = {key1: 'test1', key2: 'test2'} Handlebars.registerHelper 'show', => return this.hash In template: {{show.key1}} What am i doing wrong? Thanks!...

loop inside of loop in handlebars.js

javascript,jquery,handlebars.js
I am using handlebars.js. I have a loop of flight.LegsOut and I am really only using the "first" and the "last" of the flight.LegsOut elements. But inside of the loop I have a modal popup - tagged - "dropdown popup". The popup will show data from all of the flight.LegsOut...

Access model in controller-action?

ember.js,handlebars.js,ember-cli,controller-actions
I'm editing an object with a form and want to save the changed object from within the controller-action which is bound to the submit-button. I don't want to bind the values directly to the template. Here's the admin/edit.hbs <form> <label>Title <input name="title" type="text" {{ bind-attr value=title }} /> </label> <label>Permalink...

How do you Precompile Handlebars Templates

cordova,handlebars.js
What is the proper way to compile handlebars templates using npm. The documentation on the website is vague....

Ember - Nothing handled the action occurs

ember.js,ember-data,handlebars.js,ember-cli,handlebars
Nothing handled the action error occurs for the following code. How to resolve this? I have created a view, an object for my sample app using ember. But the action part is not working. How to bind an action to a view? HTML: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Ember...

Length check in a handlebars.js {{#if}} conditional

jquery,handlebars.js
Is there a way in handlebars JS to check length of a value? Something like this: {{#if value.length > 20} ..do something {{else}} ..do something {{/if}} ...

js event in a handlebars template

javascript,jquery,handlebars.js
When i click on a button, my template who have a table is feeded. I want to do an action when i double click to a row of a table in a handlebar template. <body> <script id="lodgerSearchResult-template" type="text/x-handlebars-template"> <div class="span12"> <table id="lodgerSearchResultTable" data-show-header="true" class="table" data-toggle="table" data-height="250"> <thead> <tr> <th>#</th> <th>Nom</th>...

What is the {{#each as}} syntax in ember?

ember.js,handlebars.js
I came across this question How to set itemController in each as (ember 1.11 beta3)? while trying to figure out some stuff about controllers, and the asker used this syntax inside their {{#each}} {#each content as |product index|}} {{index}} {{/each}} I've never seen this before and I couldn't find any...

How to use Ember query parameters with beforeModel and select?

javascript,ember.js,handlebars.js
Demo: http://jsbin.com/zexopa/1/edit?html,js,output I use the query parameters in my application. And the queryParameters are 'name' and 'category'. The 'name' parameter is used in the select and the 'category' uses the input, but there is something wrong with the select 'name' if I set it default to null. If I change...

How to include Partials defined in YMF (Assemble.io / Handlebars.js)

handlebars.js,assemble
I use assemble.io to generate some static files for a simple webpage. Now i would like to define a list of partials in YAML Front Matter that should be included in the generated page. I want this <div class="slides"> {{>slide-intro}} {{>slide-welcome}} {{>slide-goodbye}} </div> to be replaced by something like this:...

How to check if an object is empty in Meteor template?

javascript,meteor,handlebars.js,spacebars
I have a template data context like this: data = { "attribute1": { "attribute2": {} } } And in the meteor template I am doing something like this: {{#with attribute1}} {{#if attribute2}} show some content {{/if}} {{/with}} I don't want to show anything if attribute2 is an empty object. However...

event.target is undefined in events

javascript,meteor,handlebars.js,meteor-blaze,meteor-helper
How to 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...

Accesing handlebars variable via javascript

javascript,node.js,express,handlebars.js
I'm generating a handlebars view for express js framework, and I need to access the variables I pass to the view from inside a separate JavaScript file. For example: var foo = {{user.name}} Someone got an idea ? Helper ? Thanks per advance ! PokeRwOw...

How do you create a Handlebars block helper in Ember that can wrap/manipulate content?

javascript,ember.js,handlebars.js,ember-cli
I want to create a Handlebars block helper (to use in an Ember app) that wraps and escapes content. I thought it would be relatively simple, but I've spent hours on it and gotten nowhere. I want this: {{#code}} <p>Hey!</p> {{/code}} To become this: <pre> <code> &lt;p&gt;Hey!&lt;/p&gt; </code> </pre> The...

using handlebars.js for templating removes spaces in a given field

javascript,jquery,handlebars.js
I'm using the handlebars.js for templating, but I encounter some problems This is my code: var jsonData = JSON.parse(JSON.stringify(xhr)); if (jsonData.length) { $('#comments').html(""); var source_g = $('#comments_template').html(); var template_g = Handlebars.compile(source_g); for ( var i = 0; i < jsonData.length; i++) { var data = jsonData[i]; console.log("comments to display :...

Handlebar Helper to Replace URL in String with HTML String Containing the Matching URL?

javascript,regex,handlebars.js
There is a similar question, but the result is comparatively specific.. I have a string of paragraph lines that looks like this (saved from a textarea): "Here are some links\n\nhttp://www.example.com is one of them\n\nand http://duckduckgo.com is another" How would I replace each URL, http://www.example.com and http://duckduckgo.com, with: <a href="http://www.example.com" target="_blank">www.example.com</a>...

Assemble handlebar template relative to its path

gruntjs,handlebars.js,assemble
So I'm trying to look through a directory and compile all hbs files. But the thing is that the hbs file should compile in the folder it lies in. pseudo code: assemble: { options: { flatten: false, assets: 'assets', dev: true, livereloadPort: '<%- livereloadPort %>', partials: ['dev/assemble/partials/*.hbs'], layout: 'dev/assemble/banner.hbs', data:...

Cannot pass variables to a partial in handlebars 3

javascript,handlebars.js,handlebars
Tried to pass variable to a partial without success. Try 1: passing template context "product" template: From template: {{product.name}} <br> {{> product_buttons}} "product_buttons" partial: From partial: {{product.name}} Output: From template: Awesome Steel Shoes <br> [object Object] From partial: We can see 2 problems: the partial does not render the expected...

Looking at previous item in handlebars loop MeteorJS

mongodb,meteor,handlebars.js
I have a template in which I want to generate some HTML only if the current item has some different fields from the previous item. {{#each item}} // if previous item.ar == current item.var, do X // else, do Y {{/each} How can I access the previous item?...

NodeJs with Express and Handlebars - handlebars.engine is undefined

javascript,node.js,express,handlebars.js,viewengine
I am following the tutorials in O'Reilly's "Web Development with Node & Express" by Ethan Brown. They use handlebars as the view engine. Here is my code: var express = require ('express'), handlebars = require('express3-handlebars'), app = express(); handlebars.create({ defaultLayout: 'main' }); app.engine('handlebars', handlebars.engine); The problem I am having is...

RequireJS and multiple compiled Handlebar.js templates in a single file

javascript,maven,requirejs,handlebars.js
I'm new to RequireJS. I'm using RequireJS and Handlebars.js together in a Java/Maven application. I'm also using jknack's handlebars-maven-plugin to compile my Handlebars templates. The templates need to be compiled in order for them to work as part of a cross-domain solution. The plugin is compiling my templates and merging...

each over the result of a helper function?

javascript,handlebars.js
In handlebars I have registered a helper function that returns a list, for example: function myHelper() { return [ 'some val 1', 'some val 2', 'some val 3' ] } I would like to call that function and iterate over the results using Handlebars, something like this: {{#each myHelper}} <li>{{this}}</li>...

What is the best way to pass global config variables to handlebars template?

javascript,node.js,express,handlebars.js
Ive a nodejs app with express-handlebars and i am wanting to define variable for things like the 'host' address for CSS and Javascript that are currently being imported in a header.hbs file that i call form within the specific layout. Ive created a config.js file which has a number of...

how to append optionValue to the input id and label for attribute dynamically?

ember.js,handlebars.js
suppose options = ["low", "medium", "high"] {{#each optionValue in options}} <span> <input type="radio" id="screen-risk-{{optionValue}}" name="riskRating"/> <label for="screen-risk-{{optionValue}}" name="checkbox"> Low </label> </span> {{/each}} how to append optionValue to the input id and label for attribute dynamically? Without using any helpers, it should come like screen-risk-low, screen-risk-medium, screen-risk-high...

Finding a single record by id with ember and ember data

ember.js,ember-data,handlebars.js
Why can't I pass the Id as a parameter in this scenario: App.Router.map(function () { this.route("home", {path: '/'}); }); App.HomeRoute = Ember.Route.extend({ model: function () { // return this.store.find('post');//works return this.store.find('post',1);//does not }, setupController: function (controller, model) { controller.set('info', model); } }); Fiddle: http://jsfiddle.net/3bfsddvo/2/ Ref: http://emberjs.com/guides/models/finding-records/#toc_finding-a-single-record I know I am...

Looping thru Mongo database with Node.js and Handlebars

javascript,node.js,mongodb,handlebars.js
I'm new to programming and am learning Javascript and Node.js. I am looking for some help on how to pull some data from my database. I have a Mongo database with a list of job positions, there is a bool condition that is part of that each job that is...

How to add a specific sidebar to meteor route?

meteor,routes,handlebars.js
For example I have an admin area and I want to display a specific sidebar for admin navigation <body> {{#if adminRoute}} {{> sidebarAdminNav }} {{> yeld }} {{else}} {{> yeld }} {{/if} </body> ...

Add anchor to javascript array for use with handlebars.js

javascript,html,escaping,handlebars.js
I have a good number of arrays stored in a javascript variable. An example of one of my arrays is: { index: 6, template: 2, title: "Innovation Center", shortname: 'innov', projectActive: 'true', subtitle: "Construct", location: "alaska", x: 1304, y: 610, image1: "img/watt.jpg", image2: "img/image_2.jpg", bgImage: "img/bgImage.jpg", headline1: "Catapulting Ideas to...

Referencing handlebars variable in a loop

javascript,handlebars.js
I am trying to build some dropdowns in Handlebars using a compiled template but it is not able to access my variable: Handlebars: {{#each options}} <div class="control-group consumables-options"> <div class="row-fluid"> <div class="span2"> {{select 'task_services_options' ../bond_service_request_quantities quantity}} </div> </div> </div> {{/each}} JS: var html = Handlebars.templates.service_request_consumable_options({ bond_service_request_quantities: bond_quantities, options: opts });...

Linking rendered template with Angular js

javascript,jquery,angularjs,handlebars.js
My controller is defined as : broConsoleApp.controller('actionCreateController', ['$scope', '$stateParams', '$sce', function ($scope, $stateParams, $sce) { $scope.html = ""; var resp = []; var params = {}; /* lot of other things here */ $scope.getHtml = function (type) { $scope.html = ""; $.get(apiHost + "/action/type/defn/" + type).success(function (response) { resp =...

Delimiting some sibling nodes without additional element

angularjs,templates,handlebars.js
What is the equivalent angularjs template for the following handlebar template? Is there any way to achieve same result without wrapping the if block with another tag? (foo is false) <ul> <li>a</li> {{if foo}} <li>b</li> … <li>c</li> {{/if}} <li>d</li> </ul> The rendered template should be exactly: <ul> <li>a</li> <li>d</li> </ul>...

Creating complex data models in yaml front matter in Assemble

javascript,handlebars.js,assemble
Assemble front matter YAML supports dynamic data model creation at the top of a Handlebar page with this syntax --- myModel : { aFile : <%= fileName %>} --- <div> {{myModel.aFile.someProperty}} </div> where fileName is some json file. Is it possible to manipulate myModel in YAML, after creating it, and...

How to get an access in EmberJS template to a value of the object property within key stored in other variable?

javascript,ember.js,handlebars.js
I want to iterate over object properties in the specific order. I've prepared jsbin example of my usecase (with Ember.js and Handlebars). I can't find a way to make handlebars analog of var months = ['2014-01-01', '2014-02-01', '2014-03-01']; var datesByMonth = { '2014-03-01' : [ // march { date: '2014-03-10'...

Are triple brackets XSS safe in Meteor?

meteor,handlebars.js,meteor-blaze
I wonder if triple curly brackets sanitize user input within templates to be XSS safe. <script> tags won't render out, but how about other creepy XSS hacks? Thanks in advance!...

How to reference a variable outside the current block variable?

javascript,handlebars.js,mustache,handlebars
Say I have two arrays in a structure I'm passing to my template: { days: 'Mon,Tue,Wed,Thu,Fri'.split(','), times: 'Morning,Afternoon,Night'.split(',') } I want to list each day, and for each day, list each time. However, when I reference the times array inside a loop over the days array, it seems to think...

Multiple ul with single array in ember handlebars template

ember.js,handlebars.js
Lets say I've an array with 6 items and I want print them 3 per list Ex //arr = [1,2,3,4,5,6]; //html <div class="first"> <ul> <li>1</li> <li>2</li> <li>3</li> </ul> </div> <div class="second"> <ul> <li>4</li> <li>5</li> <li>6</li> </ul> </div> How can I accomplish that with ember/handlebars? Thanks...

How pass parameter in action of handlebars input component? Using Ember.js

ember.js,handlebars.js
I need to use this input component: {{input type="textarea" value=fileName class="field" action="setFileName" on="key-press"}} But I have to pass a parameter. I don't want to do: <input type="textarea" {{bind-attr value=fileName}} class="field" {{action 'setFileName' param on="keyPress"}} ...

Calculations using handlebars in Meteor

javascript,meteor,handlebars.js
I have upvotes and downvotes and they are both in the collections and are displayed in the template as {{upvotes}} and {{downvotes}}. So if I were to have a 3rd display that shows total votes, should I do it via a helper like the below (not working by the way):...

Handlebarsjs left behind expression

node.js,handlebars.js
I am looking for a solution how to compile HTML template without ignoring unfilled data using Handlebarsjs. For example: var Handlebars = require("handlebars"); var html = "<div>{{foo}}</div><div>{{foo2}}</div>"; html = Handlebars.compile(html)({ foo : "This is a sample" }); console.log(html); Is there available compiling option that could help me to left behind...

handlebars “include” “partial” ember CLI

ember.js,handlebars.js,ember-cli
I would like to abstract out pieces of html in an ember project. For example... keep the <head> in a different file and "include" it in index.hbs or something. (think php <?php include('something'); ?>) The naming conventions in ember CLI and handlebars are a little foreign so far - and...

Handlebars helpers inside loop

javascript,handlebars.js,handlebars,handlebarshelper
Template <script id='handlebar-template'> {{#each tags}} {{#isObject this}} <span>Object</span> {{else}} <span>String</span> {{/isObject}} {{/each}} </script> Script <script> Handlebars.registerHelper('isObject', function(o) { return typeof o === "object"; }); var props = {"tags": ["Google"]} var html = $("#handlebar-template").html(); var template = Handlebars.compile(html); console.log(template(props)); </script> Output Expected <span>String</span> Actual Output false else block...

How to register a Handlebars partial outside partials folder on Sails.js?

node.js,express,handlebars.js,sails.js
I have the following folder structure on my Sails.js application: assets/ myModule/ views/ partials/ Where myModule is a Backbone component (although my client is not a full Backbone application) There's a given Handlebar partial x.handlebars that need to be rendered both via server and client sides. My struggle starts when...

Access Properties of JS Object on Controller

ember.js,handlebars.js,javascript-objects
I have created an Ember.JS application where I hang some properties on the ApplicationController that need to be accessible form all over the app. One of these properties is queue (a JS object) broken down by server names (JS arrays). In my template I would like to list the items...

How can I yield multiple pieces of content into an ember.js component template?

ruby-on-rails,ember.js,handlebars.js
The goal is to define a structure of HTML that has more than one block of content that is declared by the caller. For example, a header, body, and content. The resulting markup should be: <header>My header</header> <div class="body">My body</div> <footer>My footer</footer> The template instantiating the component would define each...

Handlebars partial printing [Object object] when rendered

javascript,handlebars.js,handlebars
I'm trying to register a Handlebars partial so that it can be included in another view. I'm using Handlebars 2.0.0. Here's the template: {{> subNav}} <h1>Issue name: {{ name }}</h1> <h2>Issue id: {{ id }}</h2> <section id="issue-sections"> {{#each sections}} <li> {{> sectionsListItem}} </li> {{/each}} </section> Here is the partial: <p>This...

Handlebars looping over an Ember component simple property

ember.js,handlebars.js
In an ember component how can I generate 6 things in the template, given a component property called num with value 6? Do I have to create an array just for the purposes of this in the component? If so can someone advise the most reusable way to do this?...

EmberJS: Render default template

javascript,templates,ember.js,handlebars.js,ember-cli
I am trying to build an Ember Application which I want to render a default template of the nested route into the index route. Here is the router.js export default Router.map(function() { this.route('posts', function() { this.route('featured'); this.route('authors'); this.route('popular'); }); }); Here is the posts-index.hbs template: <div class="posts"> <h2>Welcome to your...

How to write Helpers in HTMLBars?

javascript,ember.js,handlebars.js,handlebarshelper,htmlbars
After the latest release of EmberJS v1.9.0 I am trying to move from Handlebars to HTMLbars. What I am finding very challenging is lack of documentation. I am trying to implement very simple helpers. For example take this handlebars helpers: HTML <div id="main"></div> <script type="text/x-handlebars" data-template-name="index"> {{logIt test}} <h1>{{test}}</h1> </script>...

Find last but one element in #each helper in ember

ember.js,handlebars.js,each
In my ember application I've a scenario where I want to display the last but one element of an array in a different way. {{#each item in model}} {{#if lastButOneItem}} + {{item}} {{else}} {{item}} + {{/if}} {{/each}} But I'm not sure how to put the condition for the lastButOneItem. Is...

How to register a global handlebar helper

backbone.js,handlebars.js,browserify
handlebarhelpers.js file var $ = require('jquery'), Handlebars = require('handlebars'), Backbone = require('backbone'); module.exports.ifCondhelper = function (Handlebars, options) { Handlebars.registerHelper('ifequal', function(value1, value2, options) { if(value1 === value2) { return options.fn(this); } return options.inverse(this); }); } Template {{#ifCondhelper.ifequal type ../../notificationMessage.SkuMappingNotAvailableMessageP1}} <li notid="{{id}}"><a...

How to print key and values in Meteor Template?

javascript,meteor,handlebars.js,meteor-helper
I have JSON from helper { "Name": "abc", "Age": 24, "Address" { "street" : "xyz street", "city" : "zyz city", "country" : "XY" } } I want to print the address with key and values <template name="User"> {{#with user}} Name : {{Name}} Age : {{Age}} {{#each Address}} {{key}} : {{value}}...

Display json data from helper module in hapijs using handlebars

javascript,handlebars.js,hapijs
I have a small hapijs app and want to display quotes in json format from a helper module but I can't display it. index.js: server.views({ engines: { html: require('handlebars') }, context: defaultContext, relativeTo: __dirname, path: './views', layoutPath: './views/layout', helpersPath: './views/helpers', partialsPath: './views/partials', layout: false, isCached: false }); server.route({ method: 'GET',...

Rerendering Handlebars template upon data change

jquery,handlebars.js
I have a template that shows a button based on some boolean in a JSON-object. There are two different buttons it can show. The code for compiling the template: source = $('#some-template').html(); // Get the HTML source of the template template = Handlebars.compile(source); // Compile it $('#some-div-container').html(template(someJsonObject)); Let's say the...

node express how to render handlebars html page to file

node.js,express,handlebars.js
I want to convert some html page to pdf via wkhtmltopdf. However, the html page I want to convert to pdf is dynamically generated using handlebars. So I think one solution maybe to generate the html page via handlebars but to a file (html file). Then, convert that file to...

Handling action parameter within a component in Emberjs

javascript,ember.js,handlebars.js
Why does my <button> work but the {{delete-toggle}} component gives me an undefined for the message variable? {{delete-toggle action='deleteMessage' message=message}} <button {{action 'deleteMessage' message}}>Some Action (param: {{message}}</button> import Ember from 'ember'; export default Ember.Component.extend({ tagName: '', actions: { deleteMessage(message){ console.log(message); return this.sendAction('deleteMessage', message); } } }); ...

Ember yield param passing

ember.js,handlebars.js
I'm trying to pass an argument to a yield block, however I missing something that I don't see. Here is the case: components/table-notes.hbs <table> ... <tbody> {{#each note in notes}} <tr> <td>{{yield note}}</td> ... </tr> {{/each}} </tbody> </table> elsewhere {{#table-notes notes=model.notes}} //do something with each note {{/table-notes}} Is it anything...

Using handlebarJs with Angular

angularjs,handlebars.js
I was reading about Handlebar.Js and to me it tries to imitate what Angular.Js does. My question is whether handlebarJS is mainly for frameworks which are using expressions poorly or we might need to get help from HandlebarJS inside application on Angular framework?

Checkboxes in Ember Js

javascript,ember.js,checkbox,handlebars.js
I have a data fixture adapter say.. App.Person.reopenClass({ FIXTURES: [ { id: 1, name: 'Name1', }, { id:2, name:'Name2' } ] }); In my template i want to bind this model with checkboxes..like there are two names in the model so there should be two checkboxes with name as their...

Adding view dynamically inside template Ember Js

jquery,ember.js,ember-data,handlebars.js
On click of a button i want the following to be added dynamically inside a template. {{view App.DatalistText type="text" value=test class="form-control" placeholder="Start Typing" list="names" size="50" }} <datalist id="names" value=te> {{#each model}} <option {{bindAttr value=name}}> {{/each}} </datalist> There is a div <div id="container"></div> When user clicks a button contents of div...

Registering Handlebars string comparison helper in Ember.js not working

ember.js,handlebars.js,handlebars
I'm trying to implement a string comparison helper in my ember app and I keep getting this error : Uncaught Error: Assertion Failed: A helper named if_eq could not be found I can't believe it's that complicated to compare 2 strings together, it should be a basic but seems like...

Emberjs dropdown selected option change not detected

jquery,ember.js,handlebars.js
I have an app that needs to create filters which are saved as segment. The filters have sub fields that are displayed dependent on the model selected from the dropdown list. This works fine until I click the add-more + button and select a different model from the dropdown, so...

Binding of member functions in Handlebar context entries

javascript,templates,handlebars.js
I have got a question to a consistent but also counterintuitive behavior of handlebars.js. When a member function of a variable of the context is referenced from the template, it is called in the resolving process with the current context set to this. This is the same behavior as it...

Handlebars conditionals - boolean properties only?

ember.js,handlebars.js
Quick question. Is it possible to evaluate things other than a Boolean property in a handlebars conditional? eg This works //elsewhere... myproperty = true {{#if myproperty}}... Any way other conditionals can be done? eg //elsewhere... myproperty = 3 {{#if myproperty<4}}... ...

Ember.js: conditional input attribute

ember.js,handlebars.js,htmlbars
In Ember's input helper, how can I show/hide attributes based on a condition? For example, let's say I want to show required="required" if isEditable is true and disabled="disabled" otherwise. Currently I have something like this: {{#if isEditable}} {{input value=model.name required="required"}} {{else}} {{input value=model.name disabled="disabled"}} {{/if}} ...but it would be nice...

Handlebars.js embed literal json object in data tag

javascript,jquery,json,handlebars.js,handlebars
I've recently started to use Handlebars.js and so far I'm loving it! On my current project, I'm storing a bunch of literal values in data attributes. I'm wondering if there is a way store the full JSON object in a tag for later use. Current {{#each this}} <tr data-id="{{Id}}" data-prod-code="{{ProductCode1}}"...

Accepting multiple arguments in a Handlebars helper

javascript,coffeescript,handlebars.js,handlebars,handlebarshelper
I've checked across message boards but have not found an answer to this. My goal is to create a handlebars helper that will check if all arguments passed are true, and if so, display the content. For example: {{#ifAll data.something data.somethingElse data.oneMore}} Show me if all of these arguments exist!...

Uncaught TypeError: Cannot read property 'html' of undefined

javascript,jquery,html,backbone.js,handlebars.js
I am trying to have a google map display on my webpage using backbone.js and handlebars.js, but I can't get it to display. When I load the page, I get this error in my javascript console: Uncaught TypeError: Cannot read property 'html' of undefined Does anyone know what I am...

Handlebars does not output anything

javascript,gruntjs,handlebars.js,yeoman,bower
At the start of the file I define Handlebars etc.: <!-- build:js(.) scripts/vendor.js --> <!-- bower:js --> <script src="bower_components/jquery/dist/jquery.js"></script> <script src="bower_components/bootstrap/dist/js/bootstrap.js"></script> <script src="bower_components/handlebars/handlebars.js"></script> <!-- endbower --> <!-- endbuild --> At the end of the index.html-file I pull in my Handlebars-file: <!-- build:js({app,.tmp}) scripts/main.js --> <script...

mustache {{{partial}}} vs {{> partial}}

handlebars.js,mustache,handlebars
I have a handlebars/mustache layout file in my node.js application that looks like this: {{> header}} {{> navbar}} {{{body}}} {{> footer-user}} {{> footer}} Since all five lines are includes, is there any difference between the two types of includes? Could I replace {{{body}}} with {{>body}} or {{> header}} with {{{header}}}?...

how do I omit a line when field is empty (using mustache/handlebars)

javascript,handlebars.js,mustache
i'm currently using mustache and trying to implement some basic if-else checking. In my case, I'm checking for a value in a field. for example: I have this JSON data: "AGENCIES":[ { "IASTATE":"Buenos Aires", "IAADDRESS1":"Paraguay 647 Piso 4 Of. 17\/18", "IAADDRESS3":"", "IALEGALNAME":"Silvia Stocker Australia & New Zealand Travel (ANZ Group)",...

Handlebars external markup with PHP ajax

jquery,handlebars.js
I would like to keep all my template markup files in an external html file while using jQuery ajax to communicate with the server using PHP. PHP will return only variable data in a json object. Q: How can I organize this so that using the code below my html...