SlideShare una empresa de Scribd logo
1 de 21
Descargar para leer sin conexión
Tecniche di animazione
digitale 1
Tecniche di animazione
digitale 1

Michele Bertoli
Founder / Lead Software Engineer at Igloo
igloolab.com
michele.bertoli@accademiasantagiulia.it
Client-side 1
   January 09, 2013
Agenda
Overview      5



Mustache.js   9
Overview
Definition
A template engine is software that is designed to process web
templates and content information to produce output web
documents.




                           6   Client-side / Overview
Server side (PHP)
  <?php while ( have_posts() ) : the_post(); ?>
      <article>
          <header>
              <h1>
                     <a href="<?php the_permalink(); ?> ">
                            <?php the_title(); ?>
                     </a>
              </h1>
          </header>
          <?php the_content(); ?>
      </article>
  <?php endwhile; ?>




                                7   Client-side / Overview
Server side (.NET)
  @foreach (var post in Model) {
      <article>
          <header>
              <h1>
                     <a href="@post.Permalink ">
                            @post.Title
                     </a>
              </h1>
          </header>
          @post.Content
      </article>
  }




                                8   Client-side / Overview
Mustache.js
Definition
Mustache.js is a logic-less template syntax.
It can be used for HTML, config files, source code - anything.
It works by expanding tags in a template using values
provided in a hash or object.

   http://mustache.github.com/#demo



                             10   Client-side / Mustache.js
Usage
 var view = {
   name: "World"
 };


 var template = "Hello {{name}}";


 var output = Mustache.render(template, view);




 http://jsfiddle.net/MicheleBertoli/nwNhd/



                           11   Client-side / Mustache.js
Coffee Break
Templates
A mustache template is a string that contains any number of
mustache tags.
Tags are indicated by the double mustaches that surround
them.

   {{name}}




                          13   Client-side / Mustache.js
Sections
Sections render blocks of text one or more times, depending
on the value of the key in the current context.

   http://jsfiddle.net/MicheleBertoli/nwNhd/1




                            14   Client-side / Mustache.js
Functions
If the value of a section key is a function, it is called with the
section's literal block of text, un-rendered, as its first
argument.

   http://jsfiddle.net/MicheleBertoli/nwNhd/2




                             15   Client-side / Mustache.js
Inverted sections
The block of an inverted section is rendered only if the value of
that section's tag is null, undefined, false, or an empty list.

   http://jsfiddle.net/MicheleBertoli/nwNhd/3




                             16   Client-side / Mustache.js
Comments
Comments begin with a bang and are ignored.

   <h1>Today{{! ignore me }} .</h1>




                             17   Client-side / Mustache.js
Partials
  http://jsfiddle.net/MicheleBertoli/nwNhd/4




                         18   Client-side / Mustache.js
Compiled templates
Mustache templates can be compiled into JavaScript functions
using Mustache.compile for improved rendering performance.

   http://jsfiddle.net/MicheleBertoli/nwNhd/5




                          19   Client-side / Mustache.js
Alternatives
● Handlebars   http://handlebarsjs.com/
● Jade         https://github.com/visionmedia/jade
● Underscore   http://documentcloud.github.com/underscore/#template




                     20   Client-side / Mustache.js
Thank you

Más contenido relacionado

La actualidad más candente

JavaScript Like It’s 2013
JavaScript Like It’s 2013JavaScript Like It’s 2013
JavaScript Like It’s 2013OutSystems
 
Building Web Sites With Movable Type
Building Web Sites With Movable TypeBuilding Web Sites With Movable Type
Building Web Sites With Movable TypeByrne Reese
 
7Masters CSS | Consistência visual em projetos web, por Rafael Rinaldi
7Masters CSS | Consistência visual em projetos web, por Rafael Rinaldi7Masters CSS | Consistência visual em projetos web, por Rafael Rinaldi
7Masters CSS | Consistência visual em projetos web, por Rafael RinaldiiMasters
 
Introjscb112817
Introjscb112817Introjscb112817
Introjscb112817Thinkful
 
Unity is Strength / Happy Designer 3 / 2008.03.29
Unity is Strength / Happy Designer 3 / 2008.03.29Unity is Strength / Happy Designer 3 / 2008.03.29
Unity is Strength / Happy Designer 3 / 2008.03.29guest519038
 
Devoxx France - Web Components, Polymer et Material Design
Devoxx France -  Web Components, Polymer et Material DesignDevoxx France -  Web Components, Polymer et Material Design
Devoxx France - Web Components, Polymer et Material DesignHoracio Gonzalez
 

La actualidad más candente (9)

JavaScript Like It’s 2013
JavaScript Like It’s 2013JavaScript Like It’s 2013
JavaScript Like It’s 2013
 
Building Web Sites With Movable Type
Building Web Sites With Movable TypeBuilding Web Sites With Movable Type
Building Web Sites With Movable Type
 
Web components. Compose the web.
Web components. Compose the web.Web components. Compose the web.
Web components. Compose the web.
 
7Masters CSS | Consistência visual em projetos web, por Rafael Rinaldi
7Masters CSS | Consistência visual em projetos web, por Rafael Rinaldi7Masters CSS | Consistência visual em projetos web, por Rafael Rinaldi
7Masters CSS | Consistência visual em projetos web, por Rafael Rinaldi
 
Introjscb112817
Introjscb112817Introjscb112817
Introjscb112817
 
Unity is Strength / Happy Designer 3 / 2008.03.29
Unity is Strength / Happy Designer 3 / 2008.03.29Unity is Strength / Happy Designer 3 / 2008.03.29
Unity is Strength / Happy Designer 3 / 2008.03.29
 
Devoxx France - Web Components, Polymer et Material Design
Devoxx France -  Web Components, Polymer et Material DesignDevoxx France -  Web Components, Polymer et Material Design
Devoxx France - Web Components, Polymer et Material Design
 
Mume HTML5 Intro
Mume HTML5 IntroMume HTML5 Intro
Mume HTML5 Intro
 
CSS TIPS & TRICKS
CSS TIPS & TRICKSCSS TIPS & TRICKS
CSS TIPS & TRICKS
 

Destacado

#3 - Sectioning content and outline view
#3 - Sectioning content and outline view#3 - Sectioning content and outline view
#3 - Sectioning content and outline viewiloveigloo
 
Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)iloveigloo
 
Shoppingsquare
ShoppingsquareShoppingsquare
Shoppingsquareiloveigloo
 
#2 - CSS Layouts Overview
#2 - CSS Layouts Overview#2 - CSS Layouts Overview
#2 - CSS Layouts Overviewiloveigloo
 
#1 - HTML5 Overview
#1 - HTML5 Overview#1 - HTML5 Overview
#1 - HTML5 Overviewiloveigloo
 
#4 - CSS Selectors, CSS3 and Web typography
#4 - CSS Selectors, CSS3 and Web typography#4 - CSS Selectors, CSS3 and Web typography
#4 - CSS Selectors, CSS3 and Web typographyiloveigloo
 
#7 - Client-side web apps, MVC and jQuery
#7 - Client-side web apps, MVC and jQuery#7 - Client-side web apps, MVC and jQuery
#7 - Client-side web apps, MVC and jQueryiloveigloo
 
CSS3: Ripe and Ready
CSS3: Ripe and ReadyCSS3: Ripe and Ready
CSS3: Ripe and ReadyDenise Jacobs
 
كتاب تعلم Html5 css3
كتاب تعلم Html5 css3كتاب تعلم Html5 css3
كتاب تعلم Html5 css3titifcom
 
Parse Everything With Elixir
Parse Everything With ElixirParse Everything With Elixir
Parse Everything With ElixirGabriele Lana
 
CSS3: A practical introduction (FT2010 talk)
CSS3: A practical introduction (FT2010 talk)CSS3: A practical introduction (FT2010 talk)
CSS3: A practical introduction (FT2010 talk)Lea Verou
 
CSS3 secrets: 10 things you might not know about CSS3
CSS3 secrets: 10 things you might not know about CSS3CSS3 secrets: 10 things you might not know about CSS3
CSS3 secrets: 10 things you might not know about CSS3Lea Verou
 
Conoce HTML5 y CSS3
Conoce HTML5 y CSS3Conoce HTML5 y CSS3
Conoce HTML5 y CSS3Marta Armada
 

Destacado (19)

#3 - Sectioning content and outline view
#3 - Sectioning content and outline view#3 - Sectioning content and outline view
#3 - Sectioning content and outline view
 
Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)
 
Shoppingsquare
ShoppingsquareShoppingsquare
Shoppingsquare
 
#2 - CSS Layouts Overview
#2 - CSS Layouts Overview#2 - CSS Layouts Overview
#2 - CSS Layouts Overview
 
#1 - HTML5 Overview
#1 - HTML5 Overview#1 - HTML5 Overview
#1 - HTML5 Overview
 
#4 - CSS Selectors, CSS3 and Web typography
#4 - CSS Selectors, CSS3 and Web typography#4 - CSS Selectors, CSS3 and Web typography
#4 - CSS Selectors, CSS3 and Web typography
 
#7 - Client-side web apps, MVC and jQuery
#7 - Client-side web apps, MVC and jQuery#7 - Client-side web apps, MVC and jQuery
#7 - Client-side web apps, MVC and jQuery
 
$$$ SOLDI $$$
$$$ SOLDI $$$$$$ SOLDI $$$
$$$ SOLDI $$$
 
CSS3: Ripe and Ready
CSS3: Ripe and ReadyCSS3: Ripe and Ready
CSS3: Ripe and Ready
 
كتاب تعلم Html5 css3
كتاب تعلم Html5 css3كتاب تعلم Html5 css3
كتاب تعلم Html5 css3
 
Magic of Ruby
Magic of RubyMagic of Ruby
Magic of Ruby
 
Parse Everything With Elixir
Parse Everything With ElixirParse Everything With Elixir
Parse Everything With Elixir
 
Beyond Phoenix
Beyond PhoenixBeyond Phoenix
Beyond Phoenix
 
Estilo & CSS3
Estilo & CSS3Estilo & CSS3
Estilo & CSS3
 
CSS3: A practical introduction (FT2010 talk)
CSS3: A practical introduction (FT2010 talk)CSS3: A practical introduction (FT2010 talk)
CSS3: A practical introduction (FT2010 talk)
 
CSS3 secrets: 10 things you might not know about CSS3
CSS3 secrets: 10 things you might not know about CSS3CSS3 secrets: 10 things you might not know about CSS3
CSS3 secrets: 10 things you might not know about CSS3
 
Conoce HTML5 y CSS3
Conoce HTML5 y CSS3Conoce HTML5 y CSS3
Conoce HTML5 y CSS3
 
Fundamental CSS3
Fundamental CSS3Fundamental CSS3
Fundamental CSS3
 
Fundamental HTML5
Fundamental HTML5Fundamental HTML5
Fundamental HTML5
 

Similar a #6 - Template Engine: Mustache.js

State of modern web technologies: an introduction
State of modern web technologies: an introductionState of modern web technologies: an introduction
State of modern web technologies: an introductionMichael Ahearn
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application developmentzonathen
 
Web Programming - 7 Blading Template
Web Programming - 7 Blading TemplateWeb Programming - 7 Blading Template
Web Programming - 7 Blading TemplateAndiNurkholis1
 
The Basics Angular JS
The Basics Angular JS The Basics Angular JS
The Basics Angular JS OrisysIndia
 
Create an application with ember
Create an application with ember Create an application with ember
Create an application with ember Chandra Sekar
 
AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep DiveGabriel Walt
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applicationshchen1
 
Html5 deciphered - designing concepts part 1
Html5 deciphered - designing concepts part 1Html5 deciphered - designing concepts part 1
Html5 deciphered - designing concepts part 1Paxcel Technologies
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseEPAM Systems
 
Drupal7 Theming session on the occassion of Drupal7 release party in Delhi NCR
Drupal7 Theming session on the occassion of  Drupal7 release party in Delhi NCRDrupal7 Theming session on the occassion of  Drupal7 release party in Delhi NCR
Drupal7 Theming session on the occassion of Drupal7 release party in Delhi NCRGaurav Mishra
 
Zend Framework Quick Start Walkthrough
Zend Framework Quick Start WalkthroughZend Framework Quick Start Walkthrough
Zend Framework Quick Start WalkthroughBradley Holt
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 8 ...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 8 ...Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 8 ...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 8 ...WebStackAcademy
 
Struts 2 Overview
Struts 2 OverviewStruts 2 Overview
Struts 2 Overviewskill-guru
 
ASP.NET MVC - In the Wild
ASP.NET MVC - In the WildASP.NET MVC - In the Wild
ASP.NET MVC - In the WildBrian Boatright
 
Zend_Layout & Zend_View Enhancements
Zend_Layout & Zend_View EnhancementsZend_Layout & Zend_View Enhancements
Zend_Layout & Zend_View EnhancementsRalph Schindler
 
learnpythondjangochapteroneintroduction.pptx
learnpythondjangochapteroneintroduction.pptxlearnpythondjangochapteroneintroduction.pptx
learnpythondjangochapteroneintroduction.pptxbestboybulshaawi
 
01. 02. html web engineering html &amp; introduction
01. 02. html   web engineering html &amp; introduction01. 02. html   web engineering html &amp; introduction
01. 02. html web engineering html &amp; introductionN Gull
 

Similar a #6 - Template Engine: Mustache.js (20)

State of modern web technologies: an introduction
State of modern web technologies: an introductionState of modern web technologies: an introduction
State of modern web technologies: an introduction
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application development
 
Web Programming - 7 Blading Template
Web Programming - 7 Blading TemplateWeb Programming - 7 Blading Template
Web Programming - 7 Blading Template
 
The Basics Angular JS
The Basics Angular JS The Basics Angular JS
The Basics Angular JS
 
Create an application with ember
Create an application with ember Create an application with ember
Create an application with ember
 
AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep Dive
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
Dust.js
Dust.jsDust.js
Dust.js
 
Html5 deciphered - designing concepts part 1
Html5 deciphered - designing concepts part 1Html5 deciphered - designing concepts part 1
Html5 deciphered - designing concepts part 1
 
No gEEk? No Problem!
No gEEk? No Problem!No gEEk? No Problem!
No gEEk? No Problem!
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete Course
 
Drupal7 Theming session on the occassion of Drupal7 release party in Delhi NCR
Drupal7 Theming session on the occassion of  Drupal7 release party in Delhi NCRDrupal7 Theming session on the occassion of  Drupal7 release party in Delhi NCR
Drupal7 Theming session on the occassion of Drupal7 release party in Delhi NCR
 
Zend Framework Quick Start Walkthrough
Zend Framework Quick Start WalkthroughZend Framework Quick Start Walkthrough
Zend Framework Quick Start Walkthrough
 
10 jsp-scripting-elements
10 jsp-scripting-elements10 jsp-scripting-elements
10 jsp-scripting-elements
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 8 ...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 8 ...Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 8 ...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 8 ...
 
Struts 2 Overview
Struts 2 OverviewStruts 2 Overview
Struts 2 Overview
 
ASP.NET MVC - In the Wild
ASP.NET MVC - In the WildASP.NET MVC - In the Wild
ASP.NET MVC - In the Wild
 
Zend_Layout & Zend_View Enhancements
Zend_Layout & Zend_View EnhancementsZend_Layout & Zend_View Enhancements
Zend_Layout & Zend_View Enhancements
 
learnpythondjangochapteroneintroduction.pptx
learnpythondjangochapteroneintroduction.pptxlearnpythondjangochapteroneintroduction.pptx
learnpythondjangochapteroneintroduction.pptx
 
01. 02. html web engineering html &amp; introduction
01. 02. html   web engineering html &amp; introduction01. 02. html   web engineering html &amp; introduction
01. 02. html web engineering html &amp; introduction
 

Último

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 

Último (20)

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 

#6 - Template Engine: Mustache.js

  • 2. Tecniche di animazione digitale 1 Michele Bertoli Founder / Lead Software Engineer at Igloo igloolab.com michele.bertoli@accademiasantagiulia.it
  • 3. Client-side 1 January 09, 2013
  • 4. Agenda Overview 5 Mustache.js 9
  • 6. Definition A template engine is software that is designed to process web templates and content information to produce output web documents. 6 Client-side / Overview
  • 7. Server side (PHP) <?php while ( have_posts() ) : the_post(); ?> <article> <header> <h1> <a href="<?php the_permalink(); ?> "> <?php the_title(); ?> </a> </h1> </header> <?php the_content(); ?> </article> <?php endwhile; ?> 7 Client-side / Overview
  • 8. Server side (.NET) @foreach (var post in Model) { <article> <header> <h1> <a href="@post.Permalink "> @post.Title </a> </h1> </header> @post.Content </article> } 8 Client-side / Overview
  • 10. Definition Mustache.js is a logic-less template syntax. It can be used for HTML, config files, source code - anything. It works by expanding tags in a template using values provided in a hash or object. http://mustache.github.com/#demo 10 Client-side / Mustache.js
  • 11. Usage var view = { name: "World" }; var template = "Hello {{name}}"; var output = Mustache.render(template, view); http://jsfiddle.net/MicheleBertoli/nwNhd/ 11 Client-side / Mustache.js
  • 13. Templates A mustache template is a string that contains any number of mustache tags. Tags are indicated by the double mustaches that surround them. {{name}} 13 Client-side / Mustache.js
  • 14. Sections Sections render blocks of text one or more times, depending on the value of the key in the current context. http://jsfiddle.net/MicheleBertoli/nwNhd/1 14 Client-side / Mustache.js
  • 15. Functions If the value of a section key is a function, it is called with the section's literal block of text, un-rendered, as its first argument. http://jsfiddle.net/MicheleBertoli/nwNhd/2 15 Client-side / Mustache.js
  • 16. Inverted sections The block of an inverted section is rendered only if the value of that section's tag is null, undefined, false, or an empty list. http://jsfiddle.net/MicheleBertoli/nwNhd/3 16 Client-side / Mustache.js
  • 17. Comments Comments begin with a bang and are ignored. <h1>Today{{! ignore me }} .</h1> 17 Client-side / Mustache.js
  • 19. Compiled templates Mustache templates can be compiled into JavaScript functions using Mustache.compile for improved rendering performance. http://jsfiddle.net/MicheleBertoli/nwNhd/5 19 Client-side / Mustache.js
  • 20. Alternatives ● Handlebars http://handlebarsjs.com/ ● Jade https://github.com/visionmedia/jade ● Underscore http://documentcloud.github.com/underscore/#template 20 Client-side / Mustache.js