hogan.js

For loop in Hogan JS template

天大地大妈咪最大 提交于 2019-12-06 09:29:08
问题 I am using Express JS and Hogan JS template engine. I know hogan is logic less template but I need to execute a for loop in view code to generate table fields. I have done lots of googling but I did not found any solution. I know how to do if-else in Hogan JS. I read all the documentation in Hogan JS and Mustache JS websites. I am getting values in the json format. [ { "email": "abc@example.com", "name": "abc", "date": "05/01/2015" }, { "email": "xyz@example.com", "name": "xyz", "date": "05

Iterate through keys/values in Hogan.js

a 夏天 提交于 2019-12-06 00:27:28
Is there a way to iterate through keys and values in an object using Hogan.js? I'm unable to find such documented functionality - only iteration over arrays seems to be documented. Is it even possible to iterate through objects in hogan.js (or any other moustache.js implementation)? There is no way to directly iterate over the keys and values in an object in Hogan.js, what sub_stantial is doing is essentialy iterating over an array. Depending on what you want to do you need a bit of prerender code. Supposing you have an object o that is { k1: "v1", k2: "v2" } . And you want your rendered

how to have grunt task render mustache partials to static HTML

十年热恋 提交于 2019-12-05 06:00:16
问题 Background I've been using grunt.js with a hogan.js task to build the static HTML for our internal docs. I'm learning JavaScript as I go, but I've gotten the task to work well enough for layouts and pages, but it would really help our workflow to have the hogan task render mustache partials to HTML, as in the example in this gist: https://gist.github.com/4132781 Current Setup and what I want to accomplish All of our mustache partials are in a folder called "partials". Ideally when the grunt

Hogan JS IF statements

吃可爱长大的小学妹 提交于 2019-12-05 02:09:35
I don't really like the jade syntax and was wondering if I could do this simple comparison using hoganJS instead? The example code is written in JADE. I did some googling and there seems to be mixed opinion.. I just want to know if there is a way or will I need to change something? if user li a(href='/dashboard') Dashbaord li a(href='/logout') Logout else li a(href='/login') Logi§n block body Hogan is an implementation of Mustache so the same syntax applies. {{#user}} <li><a href="/dashboard">Dashboard</a></li> <li><a href="/logout">Logout</a></li> {{/user}} {{^user}} <li><a href="/login"

For loop in Hogan JS template

别来无恙 提交于 2019-12-04 14:11:43
I am using Express JS and Hogan JS template engine. I know hogan is logic less template but I need to execute a for loop in view code to generate table fields. I have done lots of googling but I did not found any solution. I know how to do if-else in Hogan JS. I read all the documentation in Hogan JS and Mustache JS websites. I am getting values in the json format. [ { "email": "abc@example.com", "name": "abc", "date": "05/01/2015" }, { "email": "xyz@example.com", "name": "xyz", "date": "05/01/2015" } ] this is sample json, there may be any amount of data. To show this data in table in view I

Twitter typeahead.js: Possible to use Angular JS as template engine? If not how do I replace “{{}}” for Hogan/Mustache js?

我怕爱的太早我们不能终老 提交于 2019-12-04 08:41:33
问题 Hey guys I'm working with twitter's typeahead.js and I was wondering if it was possible to modify hogan.js to use something other than {{}} ? I'm looking at the minified code now and I have no idea what to change for something so simple. Doing a find and replace breaks it. I'm asking this mainly because I'm using Angular JS but twitter's typeahead requires a templating engine, causing hogan and angular's {{}} to clash. An even better solution would be simply modifying Angular JS (I know it's

how to have grunt task render mustache partials to static HTML

那年仲夏 提交于 2019-12-03 20:35:17
Background I've been using grunt.js with a hogan.js task to build the static HTML for our internal docs. I'm learning JavaScript as I go, but I've gotten the task to work well enough for layouts and pages, but it would really help our workflow to have the hogan task render mustache partials to HTML, as in the example in this gist: https://gist.github.com/4132781 Current Setup and what I want to accomplish All of our mustache partials are in a folder called "partials". Ideally when the grunt build is run, the hogan task will grab any partials from the partials folder and insert them into the

Twitter typeahead.js: Possible to use Angular JS as template engine? If not how do I replace “{{}}” for Hogan/Mustache js?

给你一囗甜甜゛ 提交于 2019-12-03 00:28:32
Hey guys I'm working with twitter's typeahead.js and I was wondering if it was possible to modify hogan.js to use something other than {{}} ? I'm looking at the minified code now and I have no idea what to change for something so simple. Doing a find and replace breaks it. I'm asking this mainly because I'm using Angular JS but twitter's typeahead requires a templating engine, causing hogan and angular's {{}} to clash. An even better solution would be simply modifying Angular JS (I know it's not a templating engine) and ditching Hogan to fit the following criteria: Any template engine will

How is internationalization configured for Hogan.js?

六眼飞鱼酱① 提交于 2019-12-01 21:46:48
I'm looking to use hogan.js to create html form a template in the browser. I've read that hogan supports i18n, but I can't find an example of how this works. How do you pass the translated text to hogan and what tag do you put in the template, I have seen both {{_i}} and {{i18n}}? It would seem I was confusing an older fork of Mustache.js from Twitter, with Hogan a separate mustache compiler from also from twitter. The fork does support an {{_i}} tag for internationalization. This will then call a global function with the name _ in which you provide you're own method for looking up the

Partials with Node.js + Express + Hogan.js

半腔热情 提交于 2019-11-28 20:33:28
I'm developing a site with Node.js + Express and using as view engine Hogan.js. This is my file app.js : /** * Module dependencies. */ var express = require('express') , routes = require('./routes') , user = require('./routes/user') , http = require('http') , path = require('path'); var app = express(); app.configure(function(){ app.set('port', process.env.PORT || 3000); app.set('views', __dirname + '/views'); app.set('view engine', 'hjs'); app.use(express.favicon()); app.use(express.logger('dev')); app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(express.cookieParser(