taking advantage of client side / javsscript templates in rich internet applications

19
Chief Technology Officer Blueliner NY www.bluelinerny.com www.mahbubblog.com Md. Mahbubur Rahman

Upload: m-mahbubur-rahman

Post on 27-Jan-2015

106 views

Category:

Technology


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Taking Advantage of Client Side / JavsScript Templates in Rich Internet Applications

Chief Technology OfficerBlueliner NY www.bluelinerny.comwww.mahbubblog.com

Md. Mahbubur Rahman

Page 2: Taking Advantage of Client Side / JavsScript Templates in Rich Internet Applications

?What is Rich Internet Applications, Btw

Page 3: Taking Advantage of Client Side / JavsScript Templates in Rich Internet Applications

Rich Internet Applications

Page 4: Taking Advantage of Client Side / JavsScript Templates in Rich Internet Applications

Templates Again ?

Page 5: Taking Advantage of Client Side / JavsScript Templates in Rich Internet Applications

Why JavaScript Templates ?JavaScript templates are rendered and cached client-side without sending an HTTP request to the server — in other words, they’re lightning fast. Speed benefits aside, JavaScript templates also afford us the opportunity to abstract the administrative UI into a simple JavaScript API.

Rich and Faster User Experience

Decrease the load on Server [ increase scalability ]

Easy to Manage

And.. Because the modern web browsers are very powerful

Page 6: Taking Advantage of Client Side / JavsScript Templates in Rich Internet Applications

Pushing Some loads to Client’s Computer

Page 7: Taking Advantage of Client Side / JavsScript Templates in Rich Internet Applications

Flow of how JavaScript Templates work

Page 8: Taking Advantage of Client Side / JavsScript Templates in Rich Internet Applications

HOW DO JAVASCRIPT TEMPLATES LOOK LIKE

HTML

JSON

<div class="entry"> <h1>{{title}}</h1>

{{#with author}} <h2>By {{firstName}} {{lastName}}</h2> {{/with}}</div>

{ title: "My first post!", author: { firstName: "Charles", lastName: "Jolley" }}

Page 9: Taking Advantage of Client Side / JavsScript Templates in Rich Internet Applications

HOW DO JAVASCRIPT TEMPLATES LOOK LIKE - 2

<script id="movieTemplate" type="text/x-jquery-tmpl"><tr>

<td>{{=Title}}</td><td>

{{#if Languages}}Alternative languages: <em>{{=Languages}}</em>.

{{else Subtitles}}Original language only... <br/>Subtitles in

<em>{{=Subtitles}}</em>.{{else}}

Original version only, without subtitles.{{/if}}

</td></tr>

</script>

Page 10: Taking Advantage of Client Side / JavsScript Templates in Rich Internet Applications

HOW DO JAVASCRIPT TEMPLATES LOOK LIKE - 3

<script type="text/javascript">var movies = [{ Title: "Meet Joe Black", Languages: "English and French", Subtitles: "English"}, { Title: "Eyes Wide Shut", Subtitles: "French and Spanish"}, { Title: "The Mighty"}, { Title: "City Hunter", Languages: "Mandarin and Chinese"}];$("#movieList").html($("#movieTemplate").render(movies));

</script>

Page 11: Taking Advantage of Client Side / JavsScript Templates in Rich Internet Applications

HOW DO JAVASCRIPT TEMPLATES LOOK LIKE – 4

Page 12: Taking Advantage of Client Side / JavsScript Templates in Rich Internet Applications

Ways of Using Visitor’s PCs.

Adobe Flash / Flex

Google Gears

Microsoft Silverlight

HTML5

Page 13: Taking Advantage of Client Side / JavsScript Templates in Rich Internet Applications

Let some computation be done by Client

Page 14: Taking Advantage of Client Side / JavsScript Templates in Rich Internet Applications

Right AJAX Data Transport

XML

JSON

HTML

Page 15: Taking Advantage of Client Side / JavsScript Templates in Rich Internet Applications

Same Template for Server side and Client Side

Ex. Mustache, Handlebar JS

Available in Ruby, JavaScript, Python, Erlang,

PHP, Perl, Objective-C, Java, .NET, Android, C++,

Go, Lua, ooc, ActionScript, ColdFusion,

Scala, Clojure, Fantom, CoffeeScript, D, and for node.js.

Page 16: Taking Advantage of Client Side / JavsScript Templates in Rich Internet Applications

Same Template for Server side and Client Side (Contd.)

Page 17: Taking Advantage of Client Side / JavsScript Templates in Rich Internet Applications

JS Templating Good when

Loading all data from the server especially in rich list displays

Adding or updating new items in lists

Anywhere you need to add new complex content to the page

Anything that requires client side HTML rendering

Page 18: Taking Advantage of Client Side / JavsScript Templates in Rich Internet Applications

JavaScript Templating best suited for

Stock Related appsWeb Admin PanelLive ScoreWeb DesktopsAny AJAX Intensive app

Page 19: Taking Advantage of Client Side / JavsScript Templates in Rich Internet Applications

Some JavaScript Templating Engines

jQuery.View (https://github.com/BorisMoore/jsviews)

jQuery View Renderer (https://github.com/BorisMoore/jsrender)

Mustache (http://mustache.github.com/)

EJS (http://embeddedjs.com/)

PURE (http://beebole.com/pure/)

HandlebarJS (http://www.handlebarsjs.com/)

UnderscoreJS (http://documentcloud.github.com/underscore/)