SlideShare a Scribd company logo
Rendering Views in
                            JavaScript
                          The New Web Architecture

                                                            Jonathan Julian
                                                            @jonathanjulian




                                          http://www.flickr.com/photos/thelightningman/5473594295/

Sunday, July 10, 2011
@jonathanjulian
                        jonathanjulian.com
                           410labs.com
                          shortmail.com




                                  http://www.flickr.com/photos/see-through-the-eye-of-g/4283298553/
Sunday, July 10, 2011
http://talkinterior.com/modern-studio-architecture-parasite-san-paolo-bank-design-romania/
Sunday, July 10, 2011
http://www.livelygrey.com/2007/08/the_pink_white_house.html

Sunday, July 10, 2011
http://www.staff.ncl.ac.uk/roger.broughton/museum/firmware/mainframe.htm
Sunday, July 10, 2011
http://www.old-computers.com/fun/default.asp?s=56
Sunday, July 10, 2011
http://splitscreencoop.com/2010/09/10/computers-programmed-to-entertain/

Sunday, July 10, 2011
Sunday, July 10, 2011
http://www.rpm-software.com/clientserver.php


Sunday, July 10, 2011
Sunday, July 10, 2011
Sunday, July 10, 2011
http://cscie12.dce.harvard.edu/lecture_notes/2010/20100421/slide43.html
Sunday, July 10, 2011
Sunday, July 10, 2011
OMG
Sunday, July 10, 2011
                        AJAX
Sunday, July 10, 2011
The New Web Architecture




                          http://talkinterior.com/modern-studio-architecture-parasite-san-paolo-bank-design-romania/
Sunday, July 10, 2011
“The New Web Architecture”
            http://www.quirkey.com/blog/2009/09/15/sammy-js-
                  couchdb-and-the-new-web-architecture/




                           http://talkinterior.com/modern-studio-architecture-parasite-san-paolo-bank-design-romania/
Sunday, July 10, 2011
The New Web Architecture

                        Server   JSON     Client
                         REST              Views
                          db             behaviour
                        Models          Controllers




Sunday, July 10, 2011
What does it look like?



Sunday, July 10, 2011
How do you build it?



Sunday, July 10, 2011
/public
                        /public/javascripts


Sunday, July 10, 2011
/src
                        (php, ruby, python, Java,
                              ColdFusion)


Sunday, July 10, 2011
Examples



Sunday, July 10, 2011
Sunday, July 10, 2011
http://www.flickr.com/photos/hatm/5704687186/




Sunday, July 10, 2011
• DIY events
                        • DIY templates
                        • models?

Sunday, July 10, 2011
Sunday, July 10, 2011
• controller
                        • DIY views
                        • plug-ins

Sunday, July 10, 2011
(function($) {
     var app = $.sammy('#main', function() {
       this.get('#/', function(context) {
         // do whatever you need to do for #/
       });
     });
     $(function() {
       app.run('#/');
     });
   })(jQuery);


Sunday, July 10, 2011
Sunday, July 10, 2011
• models
                        • views
                        • events!
                        • ajax!

Sunday, July 10, 2011
var Note = Backbone.Model.extend({
      initialize: function() { ... },
      author: function() { ... },
      allowedToEdit: function(account) {
        return true;
      }
    });

    var Notes = Backbone.Collection.extend({
      url: '/notes'
    });

                                               fetch()
                                               save()
                                               destroy()
Sunday, July 10, 2011
var Workspace = Backbone.Controller.extend({
      routes: {
         "help":                 "help",   // #help
         "search/:query":        "search", // #search/kiwis
         "search/:query/p:page": "search"  // #search/kiwis/p7
      },
      help: function() {
         ...
      },
      search: function(query, page) {
         ...
      }
    });




Sunday, July 10, 2011
var DocumentView = Backbone.View.extend({
      events: {
         "dblclick"                : "open",
         "click .icon.doc"         : "select"
      },
      render: function() {
         $(this.el).html(this.template(this.model.toJSON()));
         return this;
      },
      open: function() {
         window.open(this.model.get("viewer_url"));
      },
      select: function() {
         this.model.set({selected: true});
      },
    });


Sunday, July 10, 2011
Rendering
                                                      Views




 http://www.flickr.com/photos/aoifemac/171476309/
Sunday, July 10, 2011
Underscore                    ICanHaz
                                                 Eco




                                                                                           EJS
                        Mustache                                Mold




                          Jaml     jquery-tmpl
                                                           Weld




                                                            Pure

                                                       http://www.flickr.com/photos/alibree/244728678/
Sunday, July 10, 2011
Underscore Template
           $('#content').html(
              _.template(
                '<h1><%= name %></h1>',
                {name: 'Foo'}
              )
           );




Sunday, July 10, 2011
Mustache Template
           $('#content').html(
              Mustache.to_html(
                '<h1>{{name}}</h1>',
                {name: 'Foo'}
              )
           );




Sunday, July 10, 2011
EJS Template
           $('#content').html(
              new EJS({
                 url: ‘my_template.ejs’
              }).render({
                 name: 'Foo'
              })
           );



Sunday, July 10, 2011
ICanHaz Template
           <script id="welcome" type="text/html">
             <h1>Welcome, {{ name }}</h1>
           </script>

           <script>
             $(document).ready(function() {
               $('#content').html( ich.welcome({name: 'Username'}) );
             });
           </script>




Sunday, July 10, 2011
• jquery-tmpl - mustache-like
                        • Jaml - not much like Haml
                        • Pure - directive-based
                        • Mold - php-like
                        • Weld - uses existing divs
                        • Eco - coffeescript, ASP-like
Sunday, July 10, 2011
javascript/templates
                        javascript/templates/user.jst
                        javascript/templates/address.jst
                        javascript/templates/post.jst
                        javascript/templates/comment.jst
                        javascript/templates/comments.jst




Sunday, July 10, 2011
window.JST.address = _.template
                ("...html...");

                window.JST.address
                ({email:'joe@example.com', name:'Joe
                Bob'});




Sunday, July 10, 2011
Sunday, July 10, 2011
BITCH, PLEASE
Sunday, July 10, 2011
http://www.flickr.com/photos/davic/3358417142/


Sunday, July 10, 2011
•   more frameworks

                        •   more templating choices

                        •   adoption of REST

                        •   HTML5

                        •   Rails 3.1 includes Sprockets and CoffeeScript OUT OF THE BOX

                        •   CouchDB over HTTP

                        •   Sproutcore

                        •   node.js

                        •   node.js



Sunday, July 10, 2011
http://www.flickr.com/photos/alykat/5284308030/
Sunday, July 10, 2011
I am @jonathanjulian




                        Thanks GothamJS!



      http://www.flickr.com/photos/alykat/5284308030/
Sunday, July 10, 2011

More Related Content

Similar to Rendering Views in JavaScript - "The New Web Architecture" (20)

PDF
Changeyrmarkup
Garann Means
 
PDF
node.js for front-end developers
Garann Means
 
PDF
SeaJS - 跨环境模块化开发实践
lifesinger
 
PDF
Ready to Play: JavaScript / HTML5 Game Development
Zachary Johnson
 
PDF
Html5/CSS3 in shanghai 2010
Zi Bin Cheah
 
PDF
Web performance at WDCNZ
John Clegg
 
PDF
Node conf - building realtime webapps
Henrik Joreteg
 
PDF
Javascript Views, Client-side or Server-side with NodeJS
Sylvain Zimmer
 
PDF
A Look at the Future of HTML5
Tim Wright
 
PDF
LT 08 - Guilherme Silveira - Cache hipermidia
DNAD
 
PDF
MongoDB at Sailthru: Scaling and Schema Design
DATAVERSITY
 
PDF
Discussing Java's Future
Ray Gauss
 
PDF
Searching does not mean finding Stuff - Apache Solr for TYPO3
Olivier Dobberkau
 
PDF
Pycon2011 android programming-using_python
George Goh
 
PDF
The Fast, The Slow and the Lazy
Maurício Linhares
 
PDF
international PHP2011_ilia alshanetsky_Hidden Features of PHP
smueller_sandsmedia
 
PDF
WebShell - confoo 2011 - sean coates
Bachkoutou Toutou
 
PDF
Edted 2010 Dicas de Web
Fabio Akita
 
PDF
When?, Why? and What? of MongoDB
Flavio Percoco Premoli
 
PDF
What python can learn from java
jbellis
 
Changeyrmarkup
Garann Means
 
node.js for front-end developers
Garann Means
 
SeaJS - 跨环境模块化开发实践
lifesinger
 
Ready to Play: JavaScript / HTML5 Game Development
Zachary Johnson
 
Html5/CSS3 in shanghai 2010
Zi Bin Cheah
 
Web performance at WDCNZ
John Clegg
 
Node conf - building realtime webapps
Henrik Joreteg
 
Javascript Views, Client-side or Server-side with NodeJS
Sylvain Zimmer
 
A Look at the Future of HTML5
Tim Wright
 
LT 08 - Guilherme Silveira - Cache hipermidia
DNAD
 
MongoDB at Sailthru: Scaling and Schema Design
DATAVERSITY
 
Discussing Java's Future
Ray Gauss
 
Searching does not mean finding Stuff - Apache Solr for TYPO3
Olivier Dobberkau
 
Pycon2011 android programming-using_python
George Goh
 
The Fast, The Slow and the Lazy
Maurício Linhares
 
international PHP2011_ilia alshanetsky_Hidden Features of PHP
smueller_sandsmedia
 
WebShell - confoo 2011 - sean coates
Bachkoutou Toutou
 
Edted 2010 Dicas de Web
Fabio Akita
 
When?, Why? and What? of MongoDB
Flavio Percoco Premoli
 
What python can learn from java
jbellis
 

Recently uploaded (20)

PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
July Patch Tuesday
Ivanti
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Ad

Rendering Views in JavaScript - "The New Web Architecture"