際際滷

際際滷Share a Scribd company logo
Introduction To
Dust
What is DUST
 Dust is a Javascript templating
engine
 Designed to run asynchronously
on both the server and the browser
 Not truly Logic Less
 Dust works where Javascript
works
Advantages
Template is compiled to Javascript
Available on client side, so faster rendering and less network
load
Dust can precompile your templates , or dynamically load
them
Dust works where Javascript works, No other dependencies
Example
// Template
Hello {name}! You have {count} new messages.
// Data
{
"name": "Mick",
"count": 30
}
// Result
Hello Mick! You Have 30 new messages.
Section and context
A simple key reference will look first in the current context
and, if not found, search all higher levels up to the root looking
for the name
It will not search downward
{#A}{anotherName}{/A} outputs "rootName"
Paths
If we want to work only with the data within a specific context,
we can use dotted notation (called paths) to define the context
{A.B.name} will output "Bob"
Path notation allows you to reference a path outside a current
context
Paths
// Template
{#A.B}
Name in B = {name}, Name in A =
{A.name}
{/A.B}
// Data
{
"name": "root",
"anotherName": "root2",
"A":{
"name":"Albert",
"B":{
"name":"Bob"
}
}
}
//Result
Name in B = Bob, name in A = Albert
Explicit Context Setting
// Template
{#A:A2}
{#names}
{.} - {type}
{/names}
{/A}
// Data
{
"A":
{ names :
["Albert", "Alan"]
},
"A2":{
"type":"Student"
}
}
Passing Parameters
{#A.B foo=A.name bar=anotherName
myName="shashi"}
{foo} {name} {bar} {me}
{/A.B}
References
http://www.dustjs.com/
https://github.com/linkedin/dustjs
Ad

Recommended

Php memory-redux
Php memory-redux
nanderoo
CouchDB and Rails on the Cloud
CouchDB and Rails on the Cloud
rockyjaiswal
亠仄 弌亳仍从 - Respond in 60ms. Extremal optimization with reinventing a wheel
亠仄 弌亳仍从 - Respond in 60ms. Extremal optimization with reinventing a wheel
LEDC 2016
MongoDb - Details on the POC
MongoDb - Details on the POC
Amardeep Vishwakarma
Starting with MongoDB
Starting with MongoDB
Cesar Martinez
vOfficeware Brown Bag - NOSQL
vOfficeware Brown Bag - NOSQL
apexdodge
MongoDB NYC Python
MongoDB NYC Python
Mike Dirolf
U C2007 My S Q L Performance Cookbook
U C2007 My S Q L Performance Cookbook
guestae36d0
Data presentation with dust js technologies backing linkedin
Data presentation with dust js technologies backing linkedin
Ruhaim Izmeth
Skillwise Dust JS Template
Skillwise Dust JS Template
Skillwise Group
Velocity dust
Velocity dust
Veena Basavaraj
Leaving jsps in the dust
Leaving jsps in the dust
Veena Basavaraj
Bridging the Gap with Dust.js
Bridging the Gap with Dust.js
Jeff Harrell
Dust.js
Dust.js
Yevgeniy Brikman
Dust[in]
Dust[in]
Veena Basavaraj

More Related Content

Similar to Dust (7)

Data presentation with dust js technologies backing linkedin
Data presentation with dust js technologies backing linkedin
Ruhaim Izmeth
Skillwise Dust JS Template
Skillwise Dust JS Template
Skillwise Group
Velocity dust
Velocity dust
Veena Basavaraj
Leaving jsps in the dust
Leaving jsps in the dust
Veena Basavaraj
Bridging the Gap with Dust.js
Bridging the Gap with Dust.js
Jeff Harrell
Dust.js
Dust.js
Yevgeniy Brikman
Dust[in]
Dust[in]
Veena Basavaraj
Data presentation with dust js technologies backing linkedin
Data presentation with dust js technologies backing linkedin
Ruhaim Izmeth
Skillwise Dust JS Template
Skillwise Dust JS Template
Skillwise Group
Leaving jsps in the dust
Leaving jsps in the dust
Veena Basavaraj
Bridging the Gap with Dust.js
Bridging the Gap with Dust.js
Jeff Harrell

Dust

  • 3. Dust is a Javascript templating engine Designed to run asynchronously on both the server and the browser Not truly Logic Less Dust works where Javascript works
  • 4. Advantages Template is compiled to Javascript Available on client side, so faster rendering and less network load Dust can precompile your templates , or dynamically load them Dust works where Javascript works, No other dependencies
  • 5. Example // Template Hello {name}! You have {count} new messages. // Data { "name": "Mick", "count": 30 } // Result Hello Mick! You Have 30 new messages.
  • 6. Section and context A simple key reference will look first in the current context and, if not found, search all higher levels up to the root looking for the name It will not search downward {#A}{anotherName}{/A} outputs "rootName"
  • 7. Paths If we want to work only with the data within a specific context, we can use dotted notation (called paths) to define the context {A.B.name} will output "Bob" Path notation allows you to reference a path outside a current context
  • 8. Paths // Template {#A.B} Name in B = {name}, Name in A = {A.name} {/A.B} // Data { "name": "root", "anotherName": "root2", "A":{ "name":"Albert", "B":{ "name":"Bob" } } } //Result Name in B = Bob, name in A = Albert
  • 9. Explicit Context Setting // Template {#A:A2} {#names} {.} - {type} {/names} {/A} // Data { "A": { names : ["Albert", "Alan"] }, "A2":{ "type":"Student" } }
  • 10. Passing Parameters {#A.B foo=A.name bar=anotherName myName="shashi"} {foo} {name} {bar} {me} {/A.B}