mustache

Backbone.js Memory Management, Rising DOM Node Count

时光总嘲笑我的痴心妄想 提交于 2019-11-28 19:35:18
Situation : I'm working on a pretty decently complex single page Backbone app that could potentially be running for 8-12+ hours straight. Because of this, there's a need to ensure that the application won't leak and have a reputation for crashing after X hours or slow down dramatically. The Application : The app is built on Backbone (mv*), Zepto (similar to jquery), Curl (amd loader) & Mustache (templating). Problem : I've just conquered the event listeners. The garbage collector seems to be doing a fine job cleaning these guys up, but the DOM Node Count won't stop climbing. Questions : Is

How to handle an IF STATEMENT in a Mustache template?

白昼怎懂夜的黑 提交于 2019-11-28 19:05:40
I'm using mustache. I'm generating a list of notifications. A notification JSON object looks like: [{"id":1364,"read":true,"author_id":30,"author_name":"Mr A","author_photo":"image.jpg","story":"wants to connect","notified_type":"Friendship","action":"create"}] With mustache, how can I do a if statement or case statement based on the notified_type & action ... If notified_type == "Friendship" render ...... If notified_type == "Other && action == "invite" render..... How does that work? mu is too short Mustache templates are, by design, very simple; the homepage even says: Logic-less templates.

DOM tree based JavaScript template engines

女生的网名这么多〃 提交于 2019-11-28 18:21:29
I am looking for a new Javascript template engine to replace old jQuery Template for my client side templating needs. I'd prefer approach where the template engine deals with DOM trees instead of text strings and later dumps the content of the cooked string into innerHTML . This is better performance wise and I find DOM manipulation more proper way of constructing more of DOM tree. What options I do have for Javascript template engine which would directly create DOM trees instead of being text based engines? I like Mustache.js's logicless approach, but it seems to operate on strings only.

In Mustache, How to get the index of the current Section

自作多情 提交于 2019-11-28 16:57:38
I am using Mustache and using the data { "names": [ {"name":"John"}, {"name":"Mary"} ] } My mustache template is: {{#names}} {{name}} {{/names}} What I want to be able to do is to get an index of the current number in the array. Something like: {{#names}} {{name}} is {{index}} {{/names}} and have it print out John is 1 Mary is 2 Is it possible to get this with Mustache? or with Handlebars or another extension? For reference, this functionality is now built in to Handlebars which has compatibility with Mustache. Use {{@index}} {{#names}} {{name}} is {{@index}} {{/names}} John is 0 Mary is 1

Mustache.js - display key instead of value

早过忘川 提交于 2019-11-28 13:40:48
I am using this data here: http://pastie.org/3231052 - How can I display the key instead of the value using Mustache or Handlebars? [{"interval":"2012-01-21", "advertiser":"Advertisers 1", "offer":"Life Insurance", "cost_type":"CPA", "revenue_type":"CPA", ... etc ... }] If you want to display key-value pairs, you can write a helper in Handlebars. Handlebars.registerHelper('eachkeys', function(context, options) { var fn = options.fn, inverse = options.inverse; var ret = ""; var empty = true; for (key in context) { empty = false; break; } if (!empty) { for (key in context) { ret = ret + fn({

Mustache JS Template with JSON Collection

[亡魂溺海] 提交于 2019-11-28 10:24:03
问题 Hi this is my first attempt to use MustacheJS with a JSON webservice in .net Currently I am struggling I can't seem to find what I am doing wrong setting this basic example: My Webservice is returing the following string: [ { "ShortDescription":"BOX", "Description":"BOXING", "Id":1 }, { "ShortDescription":"EPL", "Description":"ENGLISH PREMIER LEAGUE", "Id":2 } ] I have validated its syntax with this website: http://json.parser.online.fr/ and here is the HTML code I am using: google.load(

How to do Facebook Open Graph friendly meta tags with client-side template engines like AngularJS, Mustache, Handlebars

本秂侑毒 提交于 2019-11-28 10:14:14
According to my testing, Facebook's crawlers do not render client-side templates like a browser. I want to avoid a webserver and building HTML files for Open Graph objects at all costs. I want to generate the meta tags on the fly via the URL, but it seems Facebook cannot do this. Can someone from Facebook please confirm? I asked the head of Open Graph at #mobiledevcon and she said that Facebook can render stuff like {{value}} My meta tags are as follows, and they render fine in every browser. But the Facebook Open Graph Debugger only sees the raw text, not the interpolated content. <meta

Writing a helper that produces bound results?

六眼飞鱼酱① 提交于 2019-11-28 09:10:53
I have a date/time formatting helper but what it produces does not update when the underlying property changes. This is not a surprise, but does anyone know how to produce bindings in helpers? I invoke the helper like this... {{timestamp created_at}} ...and here is the helper itself: Handlebars.registerHelper('timestamp', function(context, options) { var formatter = options.hash['format'] ? options.hash['format'] : 'hh:mm a MM-DD-YYYY'; var original_date = Ember.getPath(this, context); // same as this.get(context) ? var parsed_date = moment(original_date); var formatted_date = parsed_date

Check with mustache js if parameter is a specific value

半腔热情 提交于 2019-11-28 08:05:36
Is it possible to check in mustache js for a specific value like {{name}} == "James" ? DATA: json: { name: "James" } HTML: {{name}} //Will give me James as output {{name == "James" }} //Is it possible to check specific value? No. The idea behind mustache is that it is a logic-less templating syntax. So, no, such a logic is not possible. We call it "logic-less" because there are no if statements, else clauses, or for loops. Instead there are only tags. Some tags are replaced with a value, some nothing, and others a series of values. https://github.com/janl/mustache.js Although the question was

spring boot官方配置

孤街醉人 提交于 2019-11-28 06:42:06
#BANNER banner.charset = UTF-8 #横幅文件编码。 banner.location = classpath:banner.txt #横幅文件位置。 banner.image.location = classpath:banner.gif #横幅图像文件位置(也可以使用jpg / png)。 banner.image.width = #crs 中横幅图像的宽度(默认为76) banner.image.height = #cars 中横幅图像的高度(默认基于图像高度) banner.image.margin = #左手图像边距在字符中(默认为2) banner.image.invert = #如果图像应该针对暗终端主题反转(默认为false) #logGING logging.config = #日志配置文件的位置。例如,用于Logback的`classpath:logback.xml` logging.exception-conversion-word =%wEx #记录异常时使用的转换字。 logging.file = #日志文件名。例如`myapp.log` logging.level。* = #Log level severity mapping。例如`logging.level.org.springframework = DEBUG`