SlideShare ist ein Scribd-Unternehmen logo
1 von 22
iGears: Architect Principles
of Template Engines Design
First sight (syntax)
Code
<?php
if ($items) {
foreach ($items as $item) {
echo "* {$item}n";
}
} else {
echo "No item has been found.n";
}
?>
First sight (syntax)
First sight (syntax)
<title>{% block title %}{% endblock %}</title>
<ul>
{% for user in users %}
<li>
<a href="{{ user.url }}">{{ user.username }}</a>
</li>
{% endfor %}
</ul>
Jinja
First sight (syntax)
FreeMarker
<html>
<body>
<p>Hello ${name}! You have the
following messages:
<#list messages as m>
<p>
<b>${m.from}:</b>
{m.body}</p>
</#list>
</body>
</html>
First sight (syntax)
Smarty
<ul>
{foreach from=$myArray item=foo}
<li>{$foo}</li>
{/foreach}
</ul>
First sight (syntax)
XSLT
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/hello-world">
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<H1>
<xsl:value-of select="greeting"/>
</H1>
<xsl:apply-templates select="greeter"/>
</BODY>
</HTML>
</xsl:template>
<xsl:template match="greeter">
<DIV>from <I><xsl:value-of select="."/></I></DIV>
</xsl:template>
</xsl:stylesheet>
First sight (syntax)
ERB
<div id='content'>
<div class='left column'>
<h2>Welcome to our site!</h2>
<p><%= print_information %></p>
</div>
<div class="right column">
<%= render :partial => "sidebar" %>
</div>
</div>
#content
.left.column
%h2 Welcome to our site!
%p= print_information
.right.column
= render :partial => "sidebar"
Separate logic from view
Role
Logic
View
First step — design patterns
• MVC
• MVP
• MVVM
Application architecture
MVC
Application architecture
• Input is directed to controller
• Many-to-many relationship
between View and Controller
• View doesn’t have any
knowledge about Controller
• View is aware of the Model it is
expecting to pass on it
MVP
Application architecture
• Input is directed to View
• One-to-One relationship
between View and Presenter
• View holds the reference to it’s
Presenter and Presenter is aware
of this View
• View is not aware of the Model.
Presenter updates the Model
MVVM
Application architecture
• Input is directed to View
• One-to-Many relationship
between ViewModel and View
• ViewModel haven’t any
knowledge about View
• View is not aware of the Model.
ViewModel updates the View.
Data presentation in template
Features
Model Data Static resources
Data-bindings
• Variables from controller
• Custom variables
• Ierarchy variables (objects, associative arrays)
Features – Variables
Format Data (Modificators)
• Format numeric data
• Date format
• Client input filtering
• HTML encoding
• Static resources formating, placeholders
replacements
Features – Variables
Logic implementation
• if else operators
• inline scripts (ex. {php}{/php})
Features – Functions
Loops
• For .. in
• Loop status (odd, even, count, last, first, index)
• Hacker functions (break, continue)
Features – Functions
Caching
• Cache time
• Personalized caching
• Partial caching
• Application caching
• Static caching
• Cache control
Features - Cache
Code Reuse
• Includes other templates
• Config files usage
Features – Code Reuse
Points
• Platform
• Architecture
• Data-binding
• Functionality
• Development resources
• Code style
Don’t forget
IGears: Template Architecture and Principles

Weitere ähnliche Inhalte

Andere mochten auch

Правила хорошего SEO тона в Frontend разработке
Правила хорошего SEO тона в Frontend разработкеПравила хорошего SEO тона в Frontend разработке
Правила хорошего SEO тона в Frontend разработкеEcommerce Solution Provider SysIQ
 
Доступность веб-сайтов: WWW для всех?
Доступность веб-сайтов: WWW для всех?Доступность веб-сайтов: WWW для всех?
Доступность веб-сайтов: WWW для всех?Ecommerce Solution Provider SysIQ
 
Гибкость и Структурированность Oбъектно Oриентированноя CSS
Гибкость и Структурированность Oбъектно Oриентированноя CSSГибкость и Структурированность Oбъектно Oриентированноя CSS
Гибкость и Структурированность Oбъектно Oриентированноя CSSEcommerce Solution Provider SysIQ
 
Психология восприятия и UX дизайн
Психология восприятия и UX дизайнПсихология восприятия и UX дизайн
Психология восприятия и UX дизайнEcommerce Solution Provider SysIQ
 

Andere mochten auch (20)

Правила хорошего SEO тона в Frontend разработке
Правила хорошего SEO тона в Frontend разработкеПравила хорошего SEO тона в Frontend разработке
Правила хорошего SEO тона в Frontend разработке
 
Going global
Going globalGoing global
Going global
 
Доступность веб-сайтов: WWW для всех?
Доступность веб-сайтов: WWW для всех?Доступность веб-сайтов: WWW для всех?
Доступность веб-сайтов: WWW для всех?
 
Mastering Java ByteCode
Mastering Java ByteCodeMastering Java ByteCode
Mastering Java ByteCode
 
Lupan big enterprise ecommerce fusion 2013
Lupan   big enterprise ecommerce fusion 2013Lupan   big enterprise ecommerce fusion 2013
Lupan big enterprise ecommerce fusion 2013
 
Getting to know magento
Getting to know magentoGetting to know magento
Getting to know magento
 
Speed Up Your Website
Speed Up Your WebsiteSpeed Up Your Website
Speed Up Your Website
 
Manifest of modern engineers
Manifest of modern engineersManifest of modern engineers
Manifest of modern engineers
 
Гибкость и Структурированность Oбъектно Oриентированноя CSS
Гибкость и Структурированность Oбъектно Oриентированноя CSSГибкость и Структурированность Oбъектно Oриентированноя CSS
Гибкость и Структурированность Oбъектно Oриентированноя CSS
 
QA evolution to the present day
QA evolution to the present dayQA evolution to the present day
QA evolution to the present day
 
Management and Communications (IPAA)
Management and Communications (IPAA)Management and Communications (IPAA)
Management and Communications (IPAA)
 
Unexpected achievements 2013
Unexpected achievements 2013Unexpected achievements 2013
Unexpected achievements 2013
 
Психология восприятия и UX дизайн
Психология восприятия и UX дизайнПсихология восприятия и UX дизайн
Психология восприятия и UX дизайн
 
External Widgets Performance
External Widgets PerformanceExternal Widgets Performance
External Widgets Performance
 
All things php
All things phpAll things php
All things php
 
Frontend Servers and NGINX: What, Where and How
Frontend Servers and NGINX: What, Where and HowFrontend Servers and NGINX: What, Where and How
Frontend Servers and NGINX: What, Where and How
 
Developing for e commerce is important
Developing for e commerce is importantDeveloping for e commerce is important
Developing for e commerce is important
 
Java serialization
Java serializationJava serialization
Java serialization
 
Quick Intro to Clean Coding
Quick Intro to Clean CodingQuick Intro to Clean Coding
Quick Intro to Clean Coding
 
Seo and Marketing Requirements in Web Architecture
Seo and Marketing Requirements in Web ArchitectureSeo and Marketing Requirements in Web Architecture
Seo and Marketing Requirements in Web Architecture
 

Ähnlich wie IGears: Template Architecture and Principles

GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineYared Ayalew
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoJoaquim Rocha
 
django_introduction20141030
django_introduction20141030django_introduction20141030
django_introduction20141030Kevin Wu
 
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5Tieturi Oy
 
Building Modern Websites with ASP.NET by Rachel Appel
Building Modern Websites with ASP.NET by Rachel AppelBuilding Modern Websites with ASP.NET by Rachel Appel
Building Modern Websites with ASP.NET by Rachel Appel.NET Conf UY
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction DjangoWade Austin
 
BackboneJS Training - Giving Backbone to your applications
BackboneJS Training - Giving Backbone to your applicationsBackboneJS Training - Giving Backbone to your applications
BackboneJS Training - Giving Backbone to your applicationsJoseph Khan
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Phpfunkatron
 
MVC 6 - Tag Helpers and View Components
MVC 6 - Tag Helpers and View ComponentsMVC 6 - Tag Helpers and View Components
MVC 6 - Tag Helpers and View ComponentsDavid Paquette
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015Hossein Zahed
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2fishwarter
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2fishwarter
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014Ran Wahle
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2fishwarter
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2fishwarter
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs WorkshopRan Wahle
 

Ähnlich wie IGears: Template Architecture and Principles (20)

GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
django_introduction20141030
django_introduction20141030django_introduction20141030
django_introduction20141030
 
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
 
Asp.Net MVC 5 in Arabic
Asp.Net MVC 5 in ArabicAsp.Net MVC 5 in Arabic
Asp.Net MVC 5 in Arabic
 
Building Modern Websites with ASP.NET by Rachel Appel
Building Modern Websites with ASP.NET by Rachel AppelBuilding Modern Websites with ASP.NET by Rachel Appel
Building Modern Websites with ASP.NET by Rachel Appel
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction Django
 
BackboneJS Training - Giving Backbone to your applications
BackboneJS Training - Giving Backbone to your applicationsBackboneJS Training - Giving Backbone to your applications
BackboneJS Training - Giving Backbone to your applications
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
 
MVC 6 - Tag Helpers and View Components
MVC 6 - Tag Helpers and View ComponentsMVC 6 - Tag Helpers and View Components
MVC 6 - Tag Helpers and View Components
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
 
Introduction to AngularJs
Introduction to AngularJsIntroduction to AngularJs
Introduction to AngularJs
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
 

Mehr von Ecommerce Solution Provider SysIQ (13)

Developing for e commerce is important
Developing for e commerce is importantDeveloping for e commerce is important
Developing for e commerce is important
 
Magento code audit
Magento code auditMagento code audit
Magento code audit
 
User focused design
User focused designUser focused design
User focused design
 
Scalability and performance for e commerce
Scalability and performance for e commerceScalability and performance for e commerce
Scalability and performance for e commerce
 
non-blocking java script
non-blocking java scriptnon-blocking java script
non-blocking java script
 
Going Global
Going GlobalGoing Global
Going Global
 
QA evolution, in pictures
QA evolution, in picturesQA evolution, in pictures
QA evolution, in pictures
 
User Behavior: Interacting With Important Website Elements
User Behavior: Interacting With Important Website ElementsUser Behavior: Interacting With Important Website Elements
User Behavior: Interacting With Important Website Elements
 
Databases on Client Side
Databases on Client SideDatabases on Client Side
Databases on Client Side
 
Testing schools overview
Testing schools overviewTesting schools overview
Testing schools overview
 
Interactive web prototyping
Interactive web prototypingInteractive web prototyping
Interactive web prototyping
 
Модульные сетки в реальном мире
Модульные сетки в реальном миреМодульные сетки в реальном мире
Модульные сетки в реальном мире
 
Understanding Annotations in Java
Understanding Annotations in JavaUnderstanding Annotations in Java
Understanding Annotations in Java
 

IGears: Template Architecture and Principles

  • 1. iGears: Architect Principles of Template Engines Design
  • 2. First sight (syntax) Code <?php if ($items) { foreach ($items as $item) { echo "* {$item}n"; } } else { echo "No item has been found.n"; } ?>
  • 4. First sight (syntax) <title>{% block title %}{% endblock %}</title> <ul> {% for user in users %} <li> <a href="{{ user.url }}">{{ user.username }}</a> </li> {% endfor %} </ul> Jinja
  • 5. First sight (syntax) FreeMarker <html> <body> <p>Hello ${name}! You have the following messages: <#list messages as m> <p> <b>${m.from}:</b> {m.body}</p> </#list> </body> </html>
  • 6. First sight (syntax) Smarty <ul> {foreach from=$myArray item=foo} <li>{$foo}</li> {/foreach} </ul>
  • 7. First sight (syntax) XSLT <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/hello-world"> <HTML> <HEAD> <TITLE></TITLE> </HEAD> <BODY> <H1> <xsl:value-of select="greeting"/> </H1> <xsl:apply-templates select="greeter"/> </BODY> </HTML> </xsl:template> <xsl:template match="greeter"> <DIV>from <I><xsl:value-of select="."/></I></DIV> </xsl:template> </xsl:stylesheet>
  • 8. First sight (syntax) ERB <div id='content'> <div class='left column'> <h2>Welcome to our site!</h2> <p><%= print_information %></p> </div> <div class="right column"> <%= render :partial => "sidebar" %> </div> </div> #content .left.column %h2 Welcome to our site! %p= print_information .right.column = render :partial => "sidebar"
  • 9. Separate logic from view Role Logic View
  • 10. First step — design patterns • MVC • MVP • MVVM Application architecture
  • 11. MVC Application architecture • Input is directed to controller • Many-to-many relationship between View and Controller • View doesn’t have any knowledge about Controller • View is aware of the Model it is expecting to pass on it
  • 12. MVP Application architecture • Input is directed to View • One-to-One relationship between View and Presenter • View holds the reference to it’s Presenter and Presenter is aware of this View • View is not aware of the Model. Presenter updates the Model
  • 13. MVVM Application architecture • Input is directed to View • One-to-Many relationship between ViewModel and View • ViewModel haven’t any knowledge about View • View is not aware of the Model. ViewModel updates the View.
  • 14. Data presentation in template Features Model Data Static resources
  • 15. Data-bindings • Variables from controller • Custom variables • Ierarchy variables (objects, associative arrays) Features – Variables
  • 16. Format Data (Modificators) • Format numeric data • Date format • Client input filtering • HTML encoding • Static resources formating, placeholders replacements Features – Variables
  • 17. Logic implementation • if else operators • inline scripts (ex. {php}{/php}) Features – Functions
  • 18. Loops • For .. in • Loop status (odd, even, count, last, first, index) • Hacker functions (break, continue) Features – Functions
  • 19. Caching • Cache time • Personalized caching • Partial caching • Application caching • Static caching • Cache control Features - Cache
  • 20. Code Reuse • Includes other templates • Config files usage Features – Code Reuse
  • 21. Points • Platform • Architecture • Data-binding • Functionality • Development resources • Code style Don’t forget