SlideShare 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

More Related Content

Similar to Dust

What is Dask and How Does It Work?
What is Dask and How Does It Work?What is Dask and How Does It Work?
What is Dask and How Does It Work?
Mel Denisse
 
MySQL up and running 30 minutes.pdf
MySQL up and running 30 minutes.pdfMySQL up and running 30 minutes.pdf
MySQL up and running 30 minutes.pdf
Vinicius M Grippa
 
Migrating and living on rds aurora
Migrating and living on rds auroraMigrating and living on rds aurora
Migrating and living on rds aurora
Balazs Pocze
 
Get to know the browser better and write faster web apps
Get to know the browser better   and write faster web appsGet to know the browser better   and write faster web apps
Get to know the browser better and write faster web appsLior Bar-On
 
Introduction to MongoDB and Workshop
Introduction to MongoDB and WorkshopIntroduction to MongoDB and Workshop
Introduction to MongoDB and Workshop
AhmedabadJavaMeetup
 
Serverless Go at BuzzBird
Serverless Go at BuzzBirdServerless Go at BuzzBird
Serverless Go at BuzzBird
Vladislav Supalov
 
Back-end (Flask_AWS)
Back-end (Flask_AWS)Back-end (Flask_AWS)
Back-end (Flask_AWS)
GDSC UofT Mississauga
 
Java Developers, make the database work for you (NLJUG JFall 2010)
Java Developers, make the database work for you (NLJUG JFall 2010)Java Developers, make the database work for you (NLJUG JFall 2010)
Java Developers, make the database work for you (NLJUG JFall 2010)
Lucas Jellema
 
Scaling 101
Scaling 101Scaling 101
Scaling 101
Chris Finne
 
Elegant CSS Design In Drupal: LESS vs Sass
Elegant CSS Design In Drupal: LESS vs SassElegant CSS Design In Drupal: LESS vs Sass
Elegant CSS Design In Drupal: LESS vs SassMediacurrent
 
Can we run the Whole Web on Apache Sling?
Can we run the Whole Web on Apache Sling?Can we run the Whole Web on Apache Sling?
Can we run the Whole Web on Apache Sling?
Bertrand Delacretaz
 
10 things I’ve learnt In the clouds
10 things I’ve learnt In the clouds10 things I’ve learnt In the clouds
10 things I’ve learnt In the clouds
Stuart Lodge
 
An Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDBAn Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDB
Lee Theobald
 
USQ Landdemos Azure Data Lake
USQ Landdemos Azure Data LakeUSQ Landdemos Azure Data Lake
USQ Landdemos Azure Data Lake
Trivadis
 
Adding Data into your SOA with WSO2 WSAS
Adding Data into your SOA with WSO2 WSASAdding Data into your SOA with WSO2 WSAS
Adding Data into your SOA with WSO2 WSAS
sumedha.r
 
Apache Cassandra and Apche Spark
Apache Cassandra and Apche SparkApache Cassandra and Apche Spark
Apache Cassandra and Apche Spark
Alex Thompson
 
Spark to DocumentDB connector
Spark to DocumentDB connectorSpark to DocumentDB connector
Spark to DocumentDB connector
Denny Lee
 
Jump Start with Apache Spark 2.0 on Databricks
Jump Start with Apache Spark 2.0 on DatabricksJump Start with Apache Spark 2.0 on Databricks
Jump Start with Apache Spark 2.0 on Databricks
Anyscale
 
Triple Blitz Strike
Triple Blitz StrikeTriple Blitz Strike
Triple Blitz Strike
Denis Zhdanov
 

Similar to Dust (20)

What is Dask and How Does It Work?
What is Dask and How Does It Work?What is Dask and How Does It Work?
What is Dask and How Does It Work?
 
MySQL up and running 30 minutes.pdf
MySQL up and running 30 minutes.pdfMySQL up and running 30 minutes.pdf
MySQL up and running 30 minutes.pdf
 
Migrating and living on rds aurora
Migrating and living on rds auroraMigrating and living on rds aurora
Migrating and living on rds aurora
 
Get to know the browser better and write faster web apps
Get to know the browser better   and write faster web appsGet to know the browser better   and write faster web apps
Get to know the browser better and write faster web apps
 
Introduction to MongoDB and Workshop
Introduction to MongoDB and WorkshopIntroduction to MongoDB and Workshop
Introduction to MongoDB and Workshop
 
Serverless Go at BuzzBird
Serverless Go at BuzzBirdServerless Go at BuzzBird
Serverless Go at BuzzBird
 
Back-end (Flask_AWS)
Back-end (Flask_AWS)Back-end (Flask_AWS)
Back-end (Flask_AWS)
 
Java Developers, make the database work for you (NLJUG JFall 2010)
Java Developers, make the database work for you (NLJUG JFall 2010)Java Developers, make the database work for you (NLJUG JFall 2010)
Java Developers, make the database work for you (NLJUG JFall 2010)
 
Scaling 101 test
Scaling 101 testScaling 101 test
Scaling 101 test
 
Scaling 101
Scaling 101Scaling 101
Scaling 101
 
Elegant CSS Design In Drupal: LESS vs Sass
Elegant CSS Design In Drupal: LESS vs SassElegant CSS Design In Drupal: LESS vs Sass
Elegant CSS Design In Drupal: LESS vs Sass
 
Can we run the Whole Web on Apache Sling?
Can we run the Whole Web on Apache Sling?Can we run the Whole Web on Apache Sling?
Can we run the Whole Web on Apache Sling?
 
10 things I’ve learnt In the clouds
10 things I’ve learnt In the clouds10 things I’ve learnt In the clouds
10 things I’ve learnt In the clouds
 
An Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDBAn Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDB
 
USQ Landdemos Azure Data Lake
USQ Landdemos Azure Data LakeUSQ Landdemos Azure Data Lake
USQ Landdemos Azure Data Lake
 
Adding Data into your SOA with WSO2 WSAS
Adding Data into your SOA with WSO2 WSASAdding Data into your SOA with WSO2 WSAS
Adding Data into your SOA with WSO2 WSAS
 
Apache Cassandra and Apche Spark
Apache Cassandra and Apche SparkApache Cassandra and Apche Spark
Apache Cassandra and Apche Spark
 
Spark to DocumentDB connector
Spark to DocumentDB connectorSpark to DocumentDB connector
Spark to DocumentDB connector
 
Jump Start with Apache Spark 2.0 on Databricks
Jump Start with Apache Spark 2.0 on DatabricksJump Start with Apache Spark 2.0 on Databricks
Jump Start with Apache Spark 2.0 on Databricks
 
Triple Blitz Strike
Triple Blitz StrikeTriple Blitz Strike
Triple Blitz Strike
 

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}