Questions tagged [handlebars.js]

Handlebars is a templating library for JavaScript.

Handlebars is a template library that is, more or less, based on . Handlebars uses Mustache template syntax to render templates but it also adds these features compared to Mustache:

  • Handlebars templates are compiled
  • Handlebars adds #if, #unless, #with, and #each
  • Handlebars supports custom helpers
  • Handlebars supports paths
  • Allows use of {{this}} in blocks (which outputs the current item's string value)
  • Handlebars.SafeString() (and maybe some other methods)
  • Handlebars is 2 to 7 times faster

However Mustache supports inverted sections (i.e. if !x ...) that are not used in Handlebars

Handlebars is used in as a Templating engine, Ember.js add some additionnal builtin helpers to the vanilla Handlebars.js. can also use handlebars when installed with the hbs option : --hbs


Resources :

7662 questions
2
votes
1 answer

Handlebars two or more if condition in comparsion

I want to check two more condition in IF Helper in Handlebars. Can some one help me with it. i want something like the below one : status = "success"; {{ifCond status '==' 'success' && status '==' 'pass'}}
2
votes
2 answers

Handlebars js not iterating over object

I am building an app using node.js and am using handlebars for server and client side templating. However, I'm having trouble iterating over an object. Here's my code: My .js file: $(function () { var theTemplateScript =…
Trung Tran
  • 13,141
  • 42
  • 113
  • 200
2
votes
2 answers

Node.js Express app: if cookie is present, than add CSS class to element from server side

I have an express static site app. I calling my site's translation with a cookie in app.js: // i18n app.get('/hu', function (req, res) { // http://127.0.0.1:3000/hu res.cookie('locale', 'hu', { maxAge: 900000, httpOnly: true }); …
Lanti
  • 2,299
  • 2
  • 36
  • 69
2
votes
0 answers

webpack handlebars loader - helpers for code blocks

I'm using this handlebars loader for webpack. I checked the helpers example and have not found out how I would invoke a helper for an entire block of code, only for a text, like so: {{[transformers/embiggen] 'This should have asterisks'}} Here's my…
Christof
  • 3,777
  • 4
  • 37
  • 49
2
votes
1 answer

Helper in handlebars printing HTML tags

I have this handlebars code that is trying to dynamically create this table {{#each this}} {{#ifCond this }} {{/ifCond}} {{/each}} Now I have a handlebars helper defined like this (sending this helper in…
Nikhil Tikoo
  • 365
  • 1
  • 9
  • 31
2
votes
1 answer

Express.JS path issue with handlebars

The thing is. the "app" folder is where my node's logic sits and there you can find the views folder, with templates for handlebars (express-handlebars). On the "config" folder, there's an express.js file where express package is actually required…
2
votes
0 answers

How do I Reference a Handlebar Registered Helper in ExpressJS

I am trying to figure out how I can reference my registered handlebars helper, but the documentation isn't that clear on where the logic should exist and how it should be referenced. I have created a js file called link-shortener that contains my…
cphill
  • 5,596
  • 16
  • 89
  • 182
2
votes
1 answer

Implementing dependent picklist in node.js + express

I am new to node.js and express. I am writing a node.js application with express and express-handlebars as my templating framework. I want to implement a dependant picklist which will be rendered based on the chosen value of another picklist. So…
codeinprogress
  • 3,193
  • 7
  • 43
  • 69
2
votes
2 answers

Selecting a field in MongoDB that was passed from a data context

My app generates a table using #each events. There are 4 event tickets per row (each row represents an event) and when you click on, for example, the first ticket, this is what's executed: Template.displayEventsTable.events({ "click .buyTicket1":…
Optimae
  • 942
  • 1
  • 12
  • 23
2
votes
0 answers

How to "url-loader" images in Express + Webpack + Handlebars

Hello I am using Express with Handlebars as view engine and would like to know how to embed images in my templates and make them "visible" to Webpacks' url-loader. Maybe one possible solution would be to use handlebars-loader but I would prefer not…
crash
  • 4,152
  • 6
  • 33
  • 54
2
votes
1 answer

Bigcommerce Stencil declare custom front-matter variable

I would like to define a list of featured category IDs within my homepage template. Is it possible to define a custom variable in the front matter? I can't seem to get it working: Here is the default front-matter in templates/pages/home.html with my…
flyingL123
  • 7,686
  • 11
  • 66
  • 135
2
votes
0 answers

Assertion failed: Object(anonymous function) in all browsers

I'm trying to debug an issue with my app not stepping forward correctly (worked fine when I left it yesterday) and all it's giving me is the following error in app.js (logged from the console): Assertion failed: Object(anonymous function) @…
Peter David Carter
  • 1,981
  • 3
  • 10
  • 9
2
votes
2 answers

Compile multiple files using Handlebars

I have a templates folder and I have multiple files under it. I want to compile all these templates into a single file so that I can load it using requireJS. I know that, I can do this via build tools like Grunt, Gulp, Brunch etc What I am…
Anoop M D
  • 31
  • 5
2
votes
1 answer

Pass array to view without html encoding issue node js(handlebars)

I am making a call to the yahoo finance api which is returning a csv. I then want to convert the csv file to an array which google charts can read. The issue is when I pass the array to the view it has a bunch of html encoded characters. For…
user3788671
  • 1,977
  • 5
  • 29
  • 43
2
votes
1 answer

How to slowly pass ember component a repeating list of data

Hey so im trying to pass a component different data in a rotation, so say I have a few objects in my controller class a: { name: "a", number: 6 } b: { name: "b", number: 15 } And I want to pass them to a component in the template…
repo
  • 147
  • 1
  • 1
  • 7
1 2 3
99
100