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"

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
 

Similar to 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
 

Recently uploaded

Recently uploaded (20)

Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 

Rendering Views in JavaScript - "The New Web Architecture"