IGears: Template Architecture and Principles
Upcoming SlideShare
Loading in...5
×
 

IGears: Template Architecture and Principles

on

  • 381 views

 

Statistics

Views

Total Views
381
Views on SlideShare
330
Embed Views
51

Actions

Likes
0
Downloads
1
Comments
0

3 Embeds 51

http://iqlab.org.ua 43
http://www.iqlab.org.ua 6
http://localhost 2

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

IGears: Template Architecture and Principles IGears: Template Architecture and Principles Presentation Transcript

  • iGears: Architect Principlesof Template Engines Design
  • First sight (syntax)Code<?phpif ($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 thefollowing 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 viewRoleLogicView
  • First step — design patterns• MVC• MVP• MVVMApplication architecture
  • MVCApplication architecture• Input is directed to controller• Many-to-many relationshipbetween View and Controller• View doesn’t have anyknowledge about Controller• View is aware of the Model it isexpecting to pass on it
  • MVPApplication architecture• Input is directed to View• One-to-One relationshipbetween View and Presenter• View holds the reference to it’sPresenter and Presenter is awareof this View• View is not aware of the Model.Presenter updates the Model
  • MVVMApplication architecture• Input is directed to View• One-to-Many relationshipbetween ViewModel and View• ViewModel haven’t anyknowledge about View• View is not aware of the Model.ViewModel updates the View.
  • Data presentation in templateFeaturesModel 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, placeholdersreplacementsFeatures – 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 controlFeatures - Cache
  • Code Reuse• Includes other templates• Config files usageFeatures – Code Reuse
  • Points• Platform• Architecture• Data-binding• Functionality• Development resources• Code styleDon’t forget