Questions tagged [client-side-templating]

99 questions
351
votes
8 answers

What are the differences between Mustache.js and Handlebars.js?

Major differences I've seen are: Handlebars adds #if, #unless, #with, and #each Handlebars adds helpers Handlebars templates are compiled (Mustache can be too) Handlebars supports paths Allows use of {{this}} in blocks (which outputs the current…
41
votes
6 answers

Does handlebars.js replace newline characters with
?

Trying to use handlebars.js for templating but the library seems to ignore newlines. What is the correct way to deal with newlines? Should they be replaced manually after the templating action?
Uri
  • 20,857
  • 6
  • 38
  • 61
33
votes
2 answers

Client-side vs. server-side templating (which one?)

I've been reading some very interesting articles about the whole client vs. server rendering lately.…
basickarl
  • 25,903
  • 43
  • 172
  • 270
32
votes
4 answers

Django and client-side javascript templates

Intro I'm currently writing a very standard Django based app (basically a fancy CRM/contact list sort of thing). It's sort of working, but as I keep trying to improve the interface with more and more AJAXy UI code (using jQuery) it's starting to…
Cody Hatch
  • 8,527
  • 6
  • 27
  • 36
23
votes
3 answers

Unique ids in knockout.js templates

Suppose I have knockout.js template like this: If I render this template in…
Roman Bataev
  • 8,835
  • 2
  • 18
  • 15
19
votes
2 answers

Basic Example of Client Side Templating with Dust.js

This is my first foray into client-side templating and I want to make sure I'm understanding it and using it correctly. After reading this LinkedIn engineering blog, I decided to go with dust.js rather than mustache or handlebars. Note that this…
dougmacklin
  • 2,290
  • 9
  • 37
  • 66
10
votes
1 answer

Client-side templating language with java compiler as well (DRY templating)

I want to be able to define templates once and use them to render html from both the server-side as well as the client-side. (DRY principle and all that) The API that I'm envisioning is simply this: render(JSON, template) --> html. I'm using a…
Geert-Jan
  • 16,760
  • 10
  • 68
  • 121
9
votes
2 answers

how to use dustjs-linkedin as client side templating?

I get the idea of server and client side templating, but dust.js confuses me a little bit. In order to use dust.js for client side templating, you need three steps: complie the template load the template render the template Right? But where do the…
paynestrike
  • 3,324
  • 14
  • 42
  • 69
7
votes
3 answers

How to use precompiled templates in Handlebars with RequireJS?

I'd like to precompile my Handlebars templates, but I'm not sure how this works in development mode. Is it common practice have some background process like Guard running to constantly monitor changes to Handlebars template files? I'm using…
Chad Johnson
  • 18,956
  • 30
  • 98
  • 192
6
votes
4 answers

Place client-side JavaScript templates in HTML or JavaScript?

Should client-side templates like the following (using underscore's templating engine):

<%= bar %>

be placed in an separate HTML file, or a separate JavaScript file? I know it could work both ways. For example, a JavaScript file…
Qcom
  • 16,009
  • 27
  • 82
  • 112
6
votes
1 answer

Getting TemplateSyntaxError: unexpected char u'#' on including a Mustache template in html file served by python Google App Engine

I am getting a TemplateSyntaxError: unexpected char u'#' error, when I include a simple Mustache template in my HTML file being served by Python Google App Engine server. The mustache template that I want to include is: {{#item}} {{name}} …
6
votes
3 answers

Format Numbers and Dates in dust.js (linkedin-fork)

How can i format numbers, currency or date values within a dust.js template? Data: { today: 'Wed Apr 03 2013 10:23:34 GMT+0200 (CEST)' } Template:

Today: {today}

Like this way: (with moment.js)

Today:…

tiefenb
  • 767
  • 1
  • 12
  • 26
6
votes
6 answers

Templating in ClojureScript

I'd like to use ClojureScript to make a "single page" style web app. To that end, I need a client-side templating system. Does anyone have any experience and/or recommendations on which ClojureScript templating systems I should look into? Thanks.
Ari
  • 3,671
  • 8
  • 31
  • 51
6
votes
2 answers

Getting the last element from a JSON array in a Handlebars template

So, I found that array elements can be accessed in Handlebars using: {{myArray.2.nestedObject}} and {{myArray.0.nestedObject}} ..to get the third and first elements for instance. (handlebars-access-array-item) Is there a way to get the last element…
Sephie
  • 331
  • 1
  • 3
  • 15
5
votes
2 answers

Kendo UI MVVM - How to iterate over and render a collection within a view?

I'm simply trying to loop over an array within my Kendo.View and attempting to render a property from the element. This would be super simple in MVC Razor, e.g. @foreach( var displayLink in Model ) {

displayLink.Text

} Rather than…
1
2 3 4 5 6 7