handlebars.js

grunt-contrib-handlebars - Output is different than when I run the handlebars npm task

不打扰是莪最后的温柔 提交于 2019-12-06 01:33:54
Thank you in advance for your time and help. I'm trying to precompile handlebars (.hbs) templates using grunt-contrib-handlebars When I run the run task I end up with this: this["JST"] = this["JST"] || {}; this["JST"]["app/templates/err.hbs"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [4,'>= 1.0.0']; helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression; buffer += "<div>Error: "; if (stack1 = helpers.error) { stack1 = stack1.call(depth0,

metalsmith-collections 'path' key not accessible from Handlebars template?

我的梦境 提交于 2019-12-05 23:59:40
My template: {{#each collections }} <span class="Category__Title">{{ @key }}</span> {{#each this }} <a href="{{ this.path }}">{{ this.title }}</a> {{/each}} {{/each}} Renders ( this.path is undefined ): <span class="Category__Title">French</span> <a href="">Braised vegetables</a> <span class="Category__Title">Thai</span> <a href="">Rice noodles</a> I'm using metalsmith: metalsmith .use(collections()) .use(markdown()) .use(templates({ engine: 'handlebars', directory: 'templates' })) .use(permalinks({ pattern: ':title' })) .destination('./public') At the time of compiling, I console log to

Yeoman and handlebars templates

左心房为你撑大大i 提交于 2019-12-05 23:13:29
Is anybody using yeoman with ember? If so, how do I get yeoman to compile the handlebars templates? If possible I would like to use the rake pipeline. Has anyone come up with a solution to compile the handlebars templates from yeoman? Luke Melia Dan Gebhardt has been working on getting Ember handlebars compilation working with yeoman. You can see the fruits of his efforts here: https://github.com/dgeb/grunt-ember-templates 来源: https://stackoverflow.com/questions/12650601/yeoman-and-handlebars-templates

how to get handlebar-layouts working in node/hapi.js

拥有回忆 提交于 2019-12-05 22:30:35
I'm having trouble getting handlebars-layouts to render in a hapi.js app. The layout renders fine but the partial doesn't render at all and just has a blank. I'm declaring it like this: var handlebars = require('handlebars'), layouts = require('handlebars-layouts'); layouts(handlebars); server.views({ engines: { html: handlebars }, basePath: __dirname, path: './views', layoutPath: './views/layout', partialsPath: './views/partials', layout: true, helpersPath: './views/helpers' }); and the boiler plate layout <html> <body> {{#content "body"}} <h2>Welcome Home</h2> {{/content}} {{#content "foot"}

set the first radio button is checked in handlebars template

旧巷老猫 提交于 2019-12-05 22:28:24
问题 How can i get a easy and clear way that set the first radio button is checked in Handlebars template. tks template: <form> {{#each this}} <input value="{{value}}" /> {{/each}} </form> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ expect render: <form> <input value="val 1" checked /> <input value="val 2" /> <input value="val 3" /> </form> thanks all. 回答1: {{#each}} in Handlebars doesn't give you access to the iteration number or anything like that so you can't do it without altering your template

How to compile new templates at runtime in meteor?

家住魔仙堡 提交于 2019-12-05 22:02:59
How to compile new templates at runtime in meteor using Handlebars.js? var source = '<input type="text" value"{{title}}" />' ; var template = ***???***.compile(my_new_template, source); var context = {title: "My New Post", body: "This is my first post!"} Template.my_new_template.events({ 'click': function (e,sender) { var that=this; } }); var html = Template.my_new_template(context); $('#workspace').append(html); Currently there is no way to compile the Handlebars string directly. Meteor wraps Handlebars and only provides a compile method for an ast (abstract syntax tree) not a string directly

Handlebars showing only first three items

强颜欢笑 提交于 2019-12-05 21:33:24
I have an extensive news source (JSON), but I need to show only first three news to the user at home page. Is there a way to discard from the fourth onwards? Something like: {{#each news}} {{ if index <= 3 }} <h3>{{title}} - {{date}}</h3> <p>{{post}}</p> {{/if}} {{/each}} Is it possible with Handlebars only or do I need to use Javascript? you are going to need to use a Handlebar helper, handle bars does not do this type of conditional checking. Handlebars.registerHelper('arrayCheck', function (newsArray) { //Logic }); sebfitz I have modified your Handlebar to support a range you can define. In

VSCode : disable formatting of a specific file (or extension) [duplicate]

别等时光非礼了梦想. 提交于 2019-12-05 20:25:58
问题 This question already has answers here : How to exclude files from “format on save” in VSCode? (2 answers) Closed 10 months ago . Using Visual Studio Code, is it possible to disable the formatting of a specific file (or extension)? I try to use some Handlebars templates and I don't want VSCode to format them, at all. A simple example would be : {{test1}} {{test2}} When I save this file (I do have - and want - "editor.formatOnSave" set to true ), VsCode transforms the content to {{test1}} {

Ember.js rendering large lists without locking up the browser

不问归期 提交于 2019-12-05 19:49:14
When it comes to rendering a large list of items on the client-side, what are my options with Ember.js? Pagination comes to mind as an obvious way to decrease the rendering time, but are there any other tricks that allow you to render a big list of items without that noticeable browser freeze as the javascript executes? ember-list-view for lists ember-table for tables I tried a million different ways of rendering lists and templates without these to no avail, so hopefully this helps someone. I found a similar performance issue when rendering large lists. My use cases is to render log entries.

Meteor template helper conditional returns false consistently

半城伤御伤魂 提交于 2019-12-05 19:33:19
Im very new to Meteor but so far Im really enjoying coding on the platform. I have come up against a bit of hurdle and cant seem to find the correct way. I want to create a helper function that will check lat and long and check it against some predefined range if it falls in between these it returns true. I have included the code I currently have: Template.header.helpers({ locationCheck: function() { navigator.geolocation.getCurrentPosition(success_callback,error_callback); function success_callback(p){ // Building Latitude = 51.522206 // Building Longitude = -0.078305 var lat = parseFloat(p