Questions tagged [dot.js]

doT.js is a JavaScript templating function with emphasis on performance under V8 and Node.js.

doT.js is a JavaScript templating function with emphasis on performance under V8 and Node.js.

Useful Links:

47 questions
43
votes
1 answer

return this || (0,eval)('this');

Looking at the doT.js source: https://raw.github.com/olado/doT/master/doT.js What does this do? (function(){ return this || (0,eval)('this'); }()).doT = doT; To me it looks like it's creating a global var, window.doT. If that's all it's doing, then…
Fergal
  • 2,444
  • 2
  • 33
  • 47
20
votes
4 answers

Is there a standard for embedding JSON in HTML?

I would like to embed JSON in HTML. The most elegant solution I have found makes use of the script-tag and the mime media type application/json. Is this the…
T. Junghans
  • 10,499
  • 7
  • 46
  • 75
8
votes
3 answers

doT.js: chained if-else if in dot.js

I was trying doT.js template engine.How to do nested if-else if in dot.js like if() ..... else if ..... else if ..... else .....
Manish Kumar
  • 9,298
  • 16
  • 72
  • 128
6
votes
2 answers

dot.js loop through object

With dot.js template engine how do you loop through an object? In the example data below how do you loop through the "msg" object? { "msg": { "1": { "a": "a1" }, "2": { "b": "b2" } } }
user3658423
  • 1,746
  • 3
  • 25
  • 46
6
votes
2 answers

doT.js do something every 3rd iteration

I have a doT.js template looking like this: {{?it.books.length }} {{~it.books :value}}
  • flygge
    • 189
    • 2
    • 11
    6
    votes
    1 answer

    Recursion with doT.js

    Assuming I have a data structure like this: { list: [ { name: "1", children: [{ name: "1.1", children: [] }, { name: "1.2", children: [{ …
    Fergal
    • 2,444
    • 2
    • 33
    • 47
    5
    votes
    4 answers

    How to render doT.js templating in nodejs?

    Hi I would like to know how can I render output in dot.js templating engine. I think it's a generic question about nodejs templating.(read comments for more info). The reason why I chose this template engine instead of jade or ejs is because it…
    user
    • 2,181
    • 2
    • 20
    • 38
    4
    votes
    1 answer

    Global helper functions in doT.js templating

    I want to define and use a global helper function for the doT.js template engine how can I do this? What I want to do is is something like this. var xyz = function(p1, p2) { return p1 + p2; } And use it in a doT.js template like this: {{xyz(2,5)}}
    lhwparis
    • 230
    • 1
    • 9
    4
    votes
    2 answers

    How to create extendable controllers in ExpressJS

    I'm new to Node and I'm trying to create an MVC app with ExpressJS (http://expressjs.com/). I'm using the same folder structure as the MVC example (https://github.com/visionmedia/express/tree/master/examples/mvc) on GitHub. In my controllers folder,…
    Jonathan
    • 523
    • 7
    • 20
    4
    votes
    1 answer

    Comma separated number/function in parenthesis in JavaScript?

    I read a line from doT.js: var global = (function(){ return this || (0||eval)('this'); }()); After it was minified: l=function(){return this||(0,eval)("this")}(); So what is the (0,eval), I mean what does the comma do? I played in Chrome's…
    Mengdi Gao
    • 760
    • 8
    • 23
    3
    votes
    2 answers

    Is there a JavaScript HTML template that supports both null-coalescing ("undefined" safe) and protects from XSS?

    I was looking for a JavaScript template engine, and chose DoT.js (mostly because it's very fast) but had the following issues Null safe/Undefined safe/null-coalescing, Just like in Freemarker / VTL, I want to be able to pass foo.bar.foobar and not…
    Eran Medan
    • 41,875
    • 56
    • 175
    • 268
    3
    votes
    2 answers

    Knockout & doT.js: How to have templating with events

    So I'm wanting to replace the Knockout templating engine with doT for enhanced performance for my large-scale single-page app. I've been able to get doT.js working with knockout as the templating engine, but i'm having a big issue. I'm used to…
    LordZardeck
    • 7,108
    • 19
    • 55
    • 111
    3
    votes
    1 answer

    How to include file in doT.js templating system

    I use doT.js 1.0 for templating with requirejs. My goal is to load a file called "length.html" from another file called "freight.html". The advanced sample states that you can load files with {{#def.loadfile('/snippet.txt')}} So I tried using…
    Manuel Hoffmann
    • 537
    • 1
    • 6
    • 20
    3
    votes
    3 answers

    knockout.js and fastest template engine

    I need a faster template engine then the builtin knockout.js one. What is the fastest and how do you set it up? Any examples on the web? I have been thinking doT.js or handlebars. I want to wait for JsRender but the performance doesnt look up to…
    Mike Flynn
    • 21,905
    • 50
    • 167
    • 308
    2
    votes
    1 answer

    Nested lists with doT.js (from nested arrays/objects)

    Is there a way to generate nested lists with doT.js? Unfortunately, my code traverses only the first object in the array (g1) and ignores all following. Is there any way to solve this with doT.js? The result should look like: G1 T11 T12 T13 G2 …
    antesoles
    • 653
    • 6
    • 18
    1
    2 3 4