Enviar pesquisa
Carregar
PHPConf-TW 2012 # Twig
•
Transferir como KEY, PDF
•
1 gostou
•
2,342 visualizações
Wake Liu
Seguir
Twig - A simple, fast, modern template engine for PHP
Leia menos
Leia mais
Tecnologia
Denunciar
Compartilhar
Denunciar
Compartilhar
1 de 29
Baixar agora
Recomendados
Django at the Disco
Django at the Disco
Richard Leland
Django at the Disco
Django at the Disco
Richard Leland
Jqeury ajax plugins
Jqeury ajax plugins
Inbal Geffen
AngulrJS Overview
AngulrJS Overview
Eyal Vardi
Django Vs Rails
Django Vs Rails
Sérgio Santos
JQuery In Drupal
JQuery In Drupal
katbailey
Using JavaScript in Drupal
Using JavaScript in Drupal
katbailey
Html To JSP
Html To JSP
PlanetB4U
Recomendados
Django at the Disco
Django at the Disco
Richard Leland
Django at the Disco
Django at the Disco
Richard Leland
Jqeury ajax plugins
Jqeury ajax plugins
Inbal Geffen
AngulrJS Overview
AngulrJS Overview
Eyal Vardi
Django Vs Rails
Django Vs Rails
Sérgio Santos
JQuery In Drupal
JQuery In Drupal
katbailey
Using JavaScript in Drupal
Using JavaScript in Drupal
katbailey
Html To JSP
Html To JSP
PlanetB4U
jQuery Best Practice
jQuery Best Practice
chandrashekher786
Dundee University HackU 2013 - Mojito
Dundee University HackU 2013 - Mojito
smartads
JQuery
JQuery
Jussi Pohjolainen
Short intro to JQuery and Modernizr
Short intro to JQuery and Modernizr
Jussi Pohjolainen
Understanding backbonejs
Understanding backbonejs
Nick Lee
Backbone
Backbone
Glenn De Backer
Backbone js in drupal core
Backbone js in drupal core
Marcin Wosinek
Introducing jQuery
Introducing jQuery
Wildan Maulana
Optimizing Magento by Preloading Data
Optimizing Magento by Preloading Data
Ivan Chepurnyi
Using of TDD practices for Magento
Using of TDD practices for Magento
Ivan Chepurnyi
jQuery
jQuery
Mohammed Arif
Learning the basics of the Drupal API
Learning the basics of the Drupal API
Alexandru Badiu
AngularJS and SPA
AngularJS and SPA
Lorenzo Dematté
Jquery
Jquery
baabtra.com - No. 1 supplier of quality freshers
In-depth changes to Drupal 8 javascript
In-depth changes to Drupal 8 javascript
Théodore Biadala
Django Templates
Django Templates
Willy Liu
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Ayes Chinmay
Get AngularJS Started!
Get AngularJS Started!
Dzmitry Ivashutsin
The Django Web Application Framework 2
The Django Web Application Framework 2
fishwarter
The Django Web Application Framework 2
The Django Web Application Framework 2
fishwarter
The Django Web Application Framework 2
The Django Web Application Framework 2
fishwarter
The Django Web Application Framework 2
The Django Web Application Framework 2
fishwarter
Mais conteúdo relacionado
Mais procurados
jQuery Best Practice
jQuery Best Practice
chandrashekher786
Dundee University HackU 2013 - Mojito
Dundee University HackU 2013 - Mojito
smartads
JQuery
JQuery
Jussi Pohjolainen
Short intro to JQuery and Modernizr
Short intro to JQuery and Modernizr
Jussi Pohjolainen
Understanding backbonejs
Understanding backbonejs
Nick Lee
Backbone
Backbone
Glenn De Backer
Backbone js in drupal core
Backbone js in drupal core
Marcin Wosinek
Introducing jQuery
Introducing jQuery
Wildan Maulana
Optimizing Magento by Preloading Data
Optimizing Magento by Preloading Data
Ivan Chepurnyi
Using of TDD practices for Magento
Using of TDD practices for Magento
Ivan Chepurnyi
jQuery
jQuery
Mohammed Arif
Learning the basics of the Drupal API
Learning the basics of the Drupal API
Alexandru Badiu
AngularJS and SPA
AngularJS and SPA
Lorenzo Dematté
Jquery
Jquery
baabtra.com - No. 1 supplier of quality freshers
In-depth changes to Drupal 8 javascript
In-depth changes to Drupal 8 javascript
Théodore Biadala
Django Templates
Django Templates
Willy Liu
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Ayes Chinmay
Get AngularJS Started!
Get AngularJS Started!
Dzmitry Ivashutsin
Mais procurados
(18)
jQuery Best Practice
jQuery Best Practice
Dundee University HackU 2013 - Mojito
Dundee University HackU 2013 - Mojito
JQuery
JQuery
Short intro to JQuery and Modernizr
Short intro to JQuery and Modernizr
Understanding backbonejs
Understanding backbonejs
Backbone
Backbone
Backbone js in drupal core
Backbone js in drupal core
Introducing jQuery
Introducing jQuery
Optimizing Magento by Preloading Data
Optimizing Magento by Preloading Data
Using of TDD practices for Magento
Using of TDD practices for Magento
jQuery
jQuery
Learning the basics of the Drupal API
Learning the basics of the Drupal API
AngularJS and SPA
AngularJS and SPA
Jquery
Jquery
In-depth changes to Drupal 8 javascript
In-depth changes to Drupal 8 javascript
Django Templates
Django Templates
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Get AngularJS Started!
Get AngularJS Started!
Semelhante a PHPConf-TW 2012 # Twig
The Django Web Application Framework 2
The Django Web Application Framework 2
fishwarter
The Django Web Application Framework 2
The Django Web Application Framework 2
fishwarter
The Django Web Application Framework 2
The Django Web Application Framework 2
fishwarter
The Django Web Application Framework 2
The Django Web Application Framework 2
fishwarter
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!
Eric Palakovich Carr
Intro To Mvc Development In Php
Intro To Mvc Development In Php
funkatron
Geek Moot '09 -- Smarty 101
Geek Moot '09 -- Smarty 101
Ted Kulp
Yii Introduction
Yii Introduction
Jason Ragsdale
Django at the Disco
Django at the Disco
Richard Leland
Django at the Disco
Django at the Disco
Richard Leland
Django at the Disco
Django at the Disco
Richard Leland
Django Class-based views (Slovenian)
Django Class-based views (Slovenian)
Luka Zakrajšek
Templates
Templates
soon
Use Symfony2 components inside WordPress
Use Symfony2 components inside WordPress
Maurizio Pelizzone
Flask – Python
Flask – Python
Max Claus Nunes
TurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
Alessandro Molina
前端概述
前端概述
Ethan Zhang
Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4
DEVCON
OSDC 2009 Rails Turtorial
OSDC 2009 Rails Turtorial
Yi-Ting Cheng
8 things to know about theming in drupal 8
8 things to know about theming in drupal 8
Logan Farr
Semelhante a PHPConf-TW 2012 # Twig
(20)
The Django Web Application Framework 2
The Django Web Application Framework 2
The Django Web Application Framework 2
The Django Web Application Framework 2
The Django Web Application Framework 2
The Django Web Application Framework 2
The Django Web Application Framework 2
The Django Web Application Framework 2
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!
Intro To Mvc Development In Php
Intro To Mvc Development In Php
Geek Moot '09 -- Smarty 101
Geek Moot '09 -- Smarty 101
Yii Introduction
Yii Introduction
Django at the Disco
Django at the Disco
Django at the Disco
Django at the Disco
Django at the Disco
Django at the Disco
Django Class-based views (Slovenian)
Django Class-based views (Slovenian)
Templates
Templates
Use Symfony2 components inside WordPress
Use Symfony2 components inside WordPress
Flask – Python
Flask – Python
TurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
前端概述
前端概述
Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4
OSDC 2009 Rails Turtorial
OSDC 2009 Rails Turtorial
8 things to know about theming in drupal 8
8 things to know about theming in drupal 8
Último
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
Radu Cotescu
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 2024
Rafal Los
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Safe Software
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Martijn de Jong
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
The Digital Insurer
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
DianaGray10
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
The Digital Insurer
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
UK Journal
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
sammart93
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
wesley chun
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
Pixlogix Infotech
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
lior mazor
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
Boston Institute of Analytics
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
Gabriella Davis
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
wesley chun
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
ThousandEyes
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
Product Anonymous
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
Principled Technologies
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
Igalia
Último
(20)
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
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 2024
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
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 Business
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
PHPConf-TW 2012 # Twig
1.
TWIG
2.
About Me
Wake Liu wake.gs@gmail.com
3.
Before the session
starts
4.
Do I need
a template engine?
5.
PHP is the
most powerful template engine
6.
7.
So, we really
need a template engine ?
8.
TWIG
9.
Performance • Compile &
cache • PHP Extension - Twig_Template::getAttribute() • APC & Memcached
10.
How it feels
to use Twig
11.
Clean and Beautiful
12.
Variables •
<?php echo $name; ?> • {{ name }} • <?php echo • {{ member.nickname }} $member->nickname; ?> • {{ member[‘nickname’] }} • <?php • {{ echo member $member[‘nickname’]; ? member.nickname ?> : ‘Guest’ }}
13.
Filters / Functions •
<?php echo nl2br ($content); ?> • <?php echo html_entity_decode ($content); ?> • <?php echo rand(0, 10); ?> • {{ content|nl2br }} • {{ content|raw }} {{ content|nl2br|length }} • {{ random(10) }}
14.
Logic & Loop •
{% if %} {% elseif %} {% else %} {% endif %} • {% for key, value in data %} {% endfor %} • {% set name = ‘wake’ %}
15.
Organizational and
reusable
16.
Extends layout.html <!DOCTYPE html>
guest.html <html lang="en"> <head> <meta charset="utf-8"> {% extends layout.html %} <title>The HTML5 Herald</title> </head> <body> {% block wrapper %} default content member.html {% endblock %} {% extends layout.html %} </body> </html>
17.
Horizontal reuse
page.html navigator.html {% use navigator.html %} {% use login.html %} {% block navigator %} <div class=”wrapper”> <div class=”navigator”> {{ block (‘navigator’) }} login.html </div> <div class=”login”> {{ block (‘login’) }} {% block login %} </div> </div>
18.
Expandable
19.
Filter, Function, Macro
and others
20.
The role of
Twig
21.
Template engine
22.
View helper
23.
MVC Controller
Control ( Logic / Loop ) { C View Data handling ( Filters / Functions ) V View binding ( Structures / Macros ) Model M
24.
Hmm, it looks
not bad, but ...
25.
...... VS
26.
Some more interesting things
27.
Photo URL passing
photo.html original data <img src=” http://www/:size/photo.jpg {{ url | image_to_large }} ”> php define Twig - addFilter _LARGE_PHOTO ‘L’ _SMALL_PHOTO ‘S’ image_to_*
28.
Template driven member.php
A.html class Member { <div> function __get ($name) { {{ member.age }} $loader = “_load$name”; </div> return $this->$loader (); } B.html function _loadAge () { <div> // load from database {{ member.age }} } </div> }
29.
Thank you Q
&A
Notas do Editor
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
Baixar agora