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

+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@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 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...
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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)
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
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...
 

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