SlideShare ist ein Scribd-Unternehmen logo
1 von 49
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Ähnlich wie Rendering Views in JavaScript - "The New Web Architecture"

SeaJS - 跨环境模块化开发实践
SeaJS - 跨环境模块化开发实践SeaJS - 跨环境模块化开发实践
SeaJS - 跨环境模块化开发实践
lifesinger
 
Html5/CSS3 in shanghai 2010
Html5/CSS3 in shanghai 2010Html5/CSS3 in shanghai 2010
Html5/CSS3 in shanghai 2010
Zi Bin Cheah
 
LT 08 - Guilherme Silveira - Cache hipermidia
LT 08 - Guilherme Silveira - Cache hipermidiaLT 08 - Guilherme Silveira - Cache hipermidia
LT 08 - Guilherme Silveira - Cache hipermidia
DNAD
 
Searching does not mean finding Stuff - Apache Solr for TYPO3
Searching does not mean finding Stuff - Apache Solr for TYPO3Searching does not mean finding Stuff - Apache Solr for TYPO3
Searching does not mean finding Stuff - Apache Solr for TYPO3
Olivier Dobberkau
 
international PHP2011_ilia alshanetsky_Hidden Features of PHP
international PHP2011_ilia alshanetsky_Hidden Features of PHPinternational PHP2011_ilia alshanetsky_Hidden Features of PHP
international PHP2011_ilia alshanetsky_Hidden Features of PHP
smueller_sandsmedia
 
WebShell - confoo 2011 - sean coates
WebShell - confoo 2011 - sean coatesWebShell - confoo 2011 - sean coates
WebShell - confoo 2011 - sean coates
Bachkoutou Toutou
 
What python can learn from java
What python can learn from javaWhat python can learn from java
What python can learn from java
jbellis
 

Ähnlich wie Rendering Views in JavaScript - "The New Web Architecture" (20)

Changeyrmarkup
ChangeyrmarkupChangeyrmarkup
Changeyrmarkup
 
node.js for front-end developers
node.js for front-end developersnode.js for front-end developers
node.js for front-end developers
 
SeaJS - 跨环境模块化开发实践
SeaJS - 跨环境模块化开发实践SeaJS - 跨环境模块化开发实践
SeaJS - 跨环境模块化开发实践
 
Ready to Play: JavaScript / HTML5 Game Development
Ready to Play: JavaScript / HTML5 Game DevelopmentReady to Play: JavaScript / HTML5 Game Development
Ready to Play: JavaScript / HTML5 Game Development
 
Html5/CSS3 in shanghai 2010
Html5/CSS3 in shanghai 2010Html5/CSS3 in shanghai 2010
Html5/CSS3 in shanghai 2010
 
Web performance at WDCNZ
Web performance at WDCNZWeb performance at WDCNZ
Web performance at WDCNZ
 
Node conf - building realtime webapps
Node conf - building realtime webappsNode conf - building realtime webapps
Node conf - building realtime webapps
 
Javascript Views, Client-side or Server-side with NodeJS
Javascript Views, Client-side or Server-side with NodeJSJavascript Views, Client-side or Server-side with NodeJS
Javascript Views, Client-side or Server-side with NodeJS
 
A Look at the Future of HTML5
A Look at the Future of HTML5A Look at the Future of HTML5
A Look at the Future of HTML5
 
LT 08 - Guilherme Silveira - Cache hipermidia
LT 08 - Guilherme Silveira - Cache hipermidiaLT 08 - Guilherme Silveira - Cache hipermidia
LT 08 - Guilherme Silveira - Cache hipermidia
 
MongoDB at Sailthru: Scaling and Schema Design
MongoDB at Sailthru: Scaling and Schema DesignMongoDB at Sailthru: Scaling and Schema Design
MongoDB at Sailthru: Scaling and Schema Design
 
Discussing Java's Future
Discussing Java's FutureDiscussing Java's Future
Discussing Java's Future
 
Searching does not mean finding Stuff - Apache Solr for TYPO3
Searching does not mean finding Stuff - Apache Solr for TYPO3Searching does not mean finding Stuff - Apache Solr for TYPO3
Searching does not mean finding Stuff - Apache Solr for TYPO3
 
Pycon2011 android programming-using_python
Pycon2011 android programming-using_pythonPycon2011 android programming-using_python
Pycon2011 android programming-using_python
 
The Fast, The Slow and the Lazy
The Fast, The Slow and the LazyThe Fast, The Slow and the Lazy
The Fast, The Slow and the Lazy
 
international PHP2011_ilia alshanetsky_Hidden Features of PHP
international PHP2011_ilia alshanetsky_Hidden Features of PHPinternational PHP2011_ilia alshanetsky_Hidden Features of PHP
international PHP2011_ilia alshanetsky_Hidden Features of PHP
 
WebShell - confoo 2011 - sean coates
WebShell - confoo 2011 - sean coatesWebShell - confoo 2011 - sean coates
WebShell - confoo 2011 - sean coates
 
Edted 2010 Dicas de Web
Edted 2010 Dicas de WebEdted 2010 Dicas de Web
Edted 2010 Dicas de Web
 
When?, Why? and What? of MongoDB
When?, Why? and What? of MongoDBWhen?, Why? and What? of MongoDB
When?, Why? and What? of MongoDB
 
What python can learn from java
What python can learn from javaWhat python can learn from java
What python can learn from java
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Rendering Views in JavaScript - "The New Web Architecture"