SlideShare a Scribd company logo
1 of 27
Templating with your {{mustache}} (js)




                      Fronteers Jam Session - Oct, 5th 2011
Who




  And BEEEER
Rendering
Rendering
Rendering
Rendering



Expensive!
Rendering



Expensive!
Rendering



Expensive!



     Hard!
Rendering



Expensive!



     Hard!
Rendering



        Expensive!



             Hard!


Front
Rendering



           Expensive!



                Hard!


Front   Back
{{mustache}}




                                   what
Made by         Used by

                          etc...




Logic-less
Framework-agnostic
Shared templates (front/back end)
{{mustache}}




                                                       what
   Implementations for Javascript,
Ruby, Python, PHP, C++, Clojure,
Java, Scala etc...

  Simple!

  Fast!! Really fast!



                 ...but unfortunately not as fast as a neutrino
{{mustache}}




                                                       what
   Implementations for Javascript,
Ruby, Python, PHP, C++, Clojure,
Java, Scala etc...

  Simple!

  Fast!! Really fast!



                 ...but unfortunately not as fast as a neutrino
{{mustache}}




                                                            how
                 Simple! Really? Yes!


var user = {                                    {{tag}}
  first_name : “David”,
                          Object
  last_name : “Gilmour”
}
var tpl = “<p>Hello, {{first_name}} {{last_name}}!</p>” Template


var html = Mustache.to_html(tpl, user);      the magiccc



            “<p>Hello, David Gilmour!</p>”
{{mustache}}




                                                               how
                                                  {{#inStock}}
inStock : function(){ /*...*/ return true; }        ..render if true
                                                  {{/inStock}}


                                                   {{#guitars}}
guitars : [“ibanez”, “music man”, “gibson”]          {{.}}
                                                   {{/guitars}}


guitars : [{ name : “music man jpx”, strings:7}, ...]


                                              {{#guitars}}
                                                {{name}} {{strings}}
                   {{^guitars}}               {{/guitars}}
guitars : []         exactly! No guitars!
                   {{/guitars}}



to_unescape : “Me&You”      {{{to_unescape}}}
{{mustache}}




               how
  wait...
{{mustache}}




               how
  wait...
{{mustache}}




                        how
      wait...




...is it THAT simple?
{{mustache}}




                                           how
              wait...




  ...is it THAT simple?
Mustache.to_html(template, view,   partials)
{{mustache}}




                                                          how
              wait...




  ...is it THAT simple?
Mustache.to_html(template, view,     partials)
                 ...let’s take a look at some ‘real life’ examples
{{mustache}}


Fast! Really? Yes! Js is fast!




 data taken from “Mustache in the Front, Mustache in the Back” talk
         by Patrick Ewing - twitter developer - (@hoverbird)
{{mustache}}


                  Fast! Really? Yes! Js is fast!
Rendering time




                 HAML             ERB             {{rb}}          jQuery tpl             {{JS}}


                    data taken from “Mustache in the Front, Mustache in the Back” talk
                            by Patrick Ewing - twitter developer - (@hoverbird)
{{mustache}}


                  Fast! Really? Yes! Js is fast!
Rendering time




                 HAML             ERB             {{rb}}          jQuery tpl             {{JS}}


                    data taken from “Mustache in the Front, Mustache in the Back” talk
                            by Patrick Ewing - twitter developer - (@hoverbird)
{{mustache}}


                  Fast! Really? Yes! Js is fast!
Rendering time




                 HAML             ERB             {{rb}}          jQuery tpl             {{JS}}


                    data taken from “Mustache in the Front, Mustache in the Back” talk
                            by Patrick Ewing - twitter developer - (@hoverbird)
References




https://github.com/janl/mustache.js

https://github.com/stecb/mustachejs-examples
THANKS




@stecb

More Related Content

What's hot (9)

The Big Three
The Big ThreeThe Big Three
The Big Three
 
COSCUP: Foreign Function Call in Julia
COSCUP: Foreign Function Call in JuliaCOSCUP: Foreign Function Call in Julia
COSCUP: Foreign Function Call in Julia
 
深層学習とベイズ統計
深層学習とベイズ統計深層学習とベイズ統計
深層学習とベイズ統計
 
JavaScript Survival Guide
JavaScript Survival GuideJavaScript Survival Guide
JavaScript Survival Guide
 
Stateモナドの解説 前編
Stateモナドの解説 前編Stateモナドの解説 前編
Stateモナドの解説 前編
 
私は如何にして心配するのを止めてPyTorchを愛するようになったか
私は如何にして心配するのを止めてPyTorchを愛するようになったか私は如何にして心配するのを止めてPyTorchを愛するようになったか
私は如何にして心配するのを止めてPyTorchを愛するようになったか
 
JavaScript Patterns
JavaScript PatternsJavaScript Patterns
JavaScript Patterns
 
ベイジアンディープニューラルネット
ベイジアンディープニューラルネットベイジアンディープニューラルネット
ベイジアンディープニューラルネット
 
確率的プログラミングライブラリEdward
確率的プログラミングライブラリEdward確率的プログラミングライブラリEdward
確率的プログラミングライブラリEdward
 

Similar to Templating with your {{mustache}}js

AST Transformations
AST TransformationsAST Transformations
AST Transformations
HamletDRC
 
Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.
Peter Higgins
 

Similar to Templating with your {{mustache}}js (20)

NUS iOS Swift Talk
NUS iOS Swift TalkNUS iOS Swift Talk
NUS iOS Swift Talk
 
Building DSLs with Xtext - Eclipse Modeling Day 2009
Building DSLs with Xtext - Eclipse Modeling Day 2009Building DSLs with Xtext - Eclipse Modeling Day 2009
Building DSLs with Xtext - Eclipse Modeling Day 2009
 
AST Transformations
AST TransformationsAST Transformations
AST Transformations
 
ES6 - Level up your JavaScript Skills
ES6 - Level up your JavaScript SkillsES6 - Level up your JavaScript Skills
ES6 - Level up your JavaScript Skills
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws
 
Avoiding JavaScript Pitfalls Through Tree Hugging
Avoiding JavaScript Pitfalls Through Tree HuggingAvoiding JavaScript Pitfalls Through Tree Hugging
Avoiding JavaScript Pitfalls Through Tree Hugging
 
JSON and the APInauts
JSON and the APInautsJSON and the APInauts
JSON and the APInauts
 
What's new in Perl 5.10?
What's new in Perl 5.10?What's new in Perl 5.10?
What's new in Perl 5.10?
 
03 introduction to graph databases
03   introduction to graph databases03   introduction to graph databases
03 introduction to graph databases
 
Pattern Matching: From Small Enhancement to Major Feature (talk from JavaLand...
Pattern Matching: From Small Enhancement to Major Feature (talk from JavaLand...Pattern Matching: From Small Enhancement to Major Feature (talk from JavaLand...
Pattern Matching: From Small Enhancement to Major Feature (talk from JavaLand...
 
Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.
 
GraphQL
GraphQLGraphQL
GraphQL
 
Copy/paste detector for source code on javascript
Copy/paste detector for source code on javascript Copy/paste detector for source code on javascript
Copy/paste detector for source code on javascript
 
Hadoop Summit Europe 2014: Apache Storm Architecture
Hadoop Summit Europe 2014: Apache Storm ArchitectureHadoop Summit Europe 2014: Apache Storm Architecture
Hadoop Summit Europe 2014: Apache Storm Architecture
 
jRuby: The best of both worlds
jRuby: The best of both worldsjRuby: The best of both worlds
jRuby: The best of both worlds
 
Java 8: the good parts!
Java 8: the good parts!Java 8: the good parts!
Java 8: the good parts!
 
JavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good PartsJavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good Parts
 
GraphQL & Relay - 串起前後端世界的橋樑
GraphQL & Relay - 串起前後端世界的橋樑GraphQL & Relay - 串起前後端世界的橋樑
GraphQL & Relay - 串起前後端世界的橋樑
 
Dapper Tool - A Bundle to Make your ECL Neater
Dapper Tool - A Bundle to Make your ECL NeaterDapper Tool - A Bundle to Make your ECL Neater
Dapper Tool - A Bundle to Make your ECL Neater
 
Naïveté vs. Experience
Naïveté vs. ExperienceNaïveté vs. Experience
Naïveté vs. Experience
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
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
 

Templating with your {{mustache}}js

  • 1. Templating with your {{mustache}} (js) Fronteers Jam Session - Oct, 5th 2011
  • 2. Who And BEEEER
  • 10. Rendering Expensive! Hard! Front
  • 11. Rendering Expensive! Hard! Front Back
  • 12. {{mustache}} what Made by Used by etc... Logic-less Framework-agnostic Shared templates (front/back end)
  • 13. {{mustache}} what Implementations for Javascript, Ruby, Python, PHP, C++, Clojure, Java, Scala etc... Simple! Fast!! Really fast! ...but unfortunately not as fast as a neutrino
  • 14. {{mustache}} what Implementations for Javascript, Ruby, Python, PHP, C++, Clojure, Java, Scala etc... Simple! Fast!! Really fast! ...but unfortunately not as fast as a neutrino
  • 15. {{mustache}} how Simple! Really? Yes! var user = { {{tag}} first_name : “David”, Object last_name : “Gilmour” } var tpl = “<p>Hello, {{first_name}} {{last_name}}!</p>” Template var html = Mustache.to_html(tpl, user); the magiccc “<p>Hello, David Gilmour!</p>”
  • 16. {{mustache}} how {{#inStock}} inStock : function(){ /*...*/ return true; } ..render if true {{/inStock}} {{#guitars}} guitars : [“ibanez”, “music man”, “gibson”] {{.}} {{/guitars}} guitars : [{ name : “music man jpx”, strings:7}, ...] {{#guitars}} {{name}} {{strings}} {{^guitars}} {{/guitars}} guitars : [] exactly! No guitars! {{/guitars}} to_unescape : “Me&You” {{{to_unescape}}}
  • 17. {{mustache}} how wait...
  • 18. {{mustache}} how wait...
  • 19. {{mustache}} how wait... ...is it THAT simple?
  • 20. {{mustache}} how wait... ...is it THAT simple? Mustache.to_html(template, view, partials)
  • 21. {{mustache}} how wait... ...is it THAT simple? Mustache.to_html(template, view, partials) ...let’s take a look at some ‘real life’ examples
  • 22. {{mustache}} Fast! Really? Yes! Js is fast! data taken from “Mustache in the Front, Mustache in the Back” talk by Patrick Ewing - twitter developer - (@hoverbird)
  • 23. {{mustache}} Fast! Really? Yes! Js is fast! Rendering time HAML ERB {{rb}} jQuery tpl {{JS}} data taken from “Mustache in the Front, Mustache in the Back” talk by Patrick Ewing - twitter developer - (@hoverbird)
  • 24. {{mustache}} Fast! Really? Yes! Js is fast! Rendering time HAML ERB {{rb}} jQuery tpl {{JS}} data taken from “Mustache in the Front, Mustache in the Back” talk by Patrick Ewing - twitter developer - (@hoverbird)
  • 25. {{mustache}} Fast! Really? Yes! Js is fast! Rendering time HAML ERB {{rb}} jQuery tpl {{JS}} data taken from “Mustache in the Front, Mustache in the Back” talk by Patrick Ewing - twitter developer - (@hoverbird)

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n