SKILLWISE-DUST JS
TEMPLATE
Dust JS Template
How to Dust…?
• Dust is a JavaScript templating engine
designed to provide a clean seperation
between presentation and logic without
sacrificing the ease of use.
• A pure javascript libraries, Dust runs in both
browser-side and server-side environments.
What is Dust…?
• Dust is a templating language.
• Its gonna go logic less.
• JS Templating
App Development,
Simplified
What is an App…?
• Not just mobile
• Web
• Mobile
• Desktop
Goal of App Development…?
• Presentation
• Meats
• Content
Why JavaScript Templating…?
• Faster
• Cheaper
• Easier
Leading Template Engines…?
• Logic-Less Templates
• Jade(Node template Engine)
• Hogan.js
• EJS
<%Emdedded js%>
• Dust
There are atleast a Dozen more…
Differences…?
• Logic
• Syntax
• Helpers
The case for Dust.js…?
Reason#1
• Easy to use
• Well documented
• Clear Syntax
• Rich Features
<div class=ā€œcontrol-groupā€>
<label class=ā€œcontrol-labelā€> RDI office:</label>
<div class=ā€œcontrolsā€>
<select name=ā€œā€ class=ā€œselect-2ā€>
{#offices}
<option value=ā€œ{office code}ā€>
{office notation}</option>
{offices}
</select></div></div>
Reason#2
• LinkedIn
• Paypal
• Actively Developed
• Battle Tested
• Community Support
Reason#3
• DRY
• Partials
<form-class=ā€œform-horizontalā€>
<legend> job listening request</legend>
<fieldset>
<div class=ā€œrowā€>
<div class=ā€œspan7ā€>
{>office/}
{>priority/}
{>notes/}
</div></div></fieldset></form>
Blocks…?
• 1. Define blocks
<div class=ā€œpageā€>
<h1>{+pageHeader} our Awesome App
{/pageHeader}</h1>
<div class=ā€œbody contentā€>
<+body content/}
</div>
</div>
2.Add Content
{>ā€base-templateā€/}
{<body content}
<p> All About RDI </p>
<ul>
<li>abc</li>
<li>xyz</li>
</ul>
{/body content}
Many ways to keep your app lean &
clean
Reason#4
• Data Referencing
• Bottom up
• All your JSON
• Sets Dust Apart
• Doctivity.io Tried out
• Handle Bars.js
• Dust.js
The problem is:
• Nested data references
• What is your partial needs access to data
• Outside the loop…?
{
team:{id:1234, name:ā€team demoā€},
Items:[
{id:678, name:ā€marry.jpgā€,
thumbnail=ā€œassets/678/x90.pngā€}
{id:679, name:ā€john.jpgā€,
thumbnail:ā€assets/679/x90.png}
]
}
• {@eq}
key equals
{@key= role value=ā€œbmā€}
<a href=ā€œ#job-requestā€ class=ā€œbtn btn-dangerā€>
</div>
{/eq}
{@size}
Length of Array
<span class=ā€œjobs countā€>
{@size key=items}
{/size} Total jobs </span>
Several more helpers
(or)
Write your own!
How it works…?
1.Dust for mark up 2.JSON for data
-t =ā€œHello{name}! Json= {
You have {count} new ā€œnameā€: ā€œjamesā€,
Messages from ā€œcountā€:2,
{#people} ā€œpeopleā€ : [{ā€œnameā€: ā€œjimā€
{name}, ā€œdistanceā€ : ā€œ2ā€
{/people} },
{ā€œnameā€: ā€œeranā€,
ā€œdistanceā€: ā€œ1ā€}]
}
3. java script for render
Dust.render(-t.json, function(error,data)
{
$(ā€œmydivā€).html(data);
}
4. HTML
Hello james. You have 2 new messages
From jim,eran
Skillwise Dust JS Template

Skillwise Dust JS Template