Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Perch CMS Template Engine
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Drew McLellan
September 10, 2013
Technology
0
240
Perch CMS Template Engine
How we wrote a template engine for Perch CMS
Drew McLellan
September 10, 2013
Tweet
Share
More Decks by Drew McLellan
See All by Drew McLellan
HTML5 APIs PHP Yorkshire 2017
drewm
1
200
HTML5 APIs Confoo Montreal
drewm
1
260
PHP Payments with Omnipay
drewm
0
120
HTML5 APIs Confoo Vancouver
drewm
0
290
Learn to Love Regular Expressions
drewm
0
160
Ecommerce Projects with Moltin
drewm
0
690
Writing Portable PHP
drewm
0
130
Getting to Grips with Regular Expressions
drewm
1
270
Back to Front Performance - Oct 2013
drewm
0
130
Other Decks in Technology
See All in Technology
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.3k
30万人の同時アクセスに耐えたい!新サービスの盤石なリリースを支える負荷試験 / SRE Kaigi 2026
genda
1
310
20260204_Midosuji_Tech
takuyay0ne
0
120
日本の85%が使う公共SaaSは、どう育ったのか
taketakekaho
1
140
Data Hubグループ 紹介資料
sansan33
PRO
0
2.7k
外部キー制約の知っておいて欲しいこと - RDBMSを正しく使うために必要なこと / FOREIGN KEY Night
soudai
PRO
12
4.8k
ブロックテーマでサイトをリニューアルした話 / 2026-01-31 Kansai WordPress Meetup
torounit
0
450
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
42k
CDKで始めるTypeScript開発のススメ
tsukuboshi
1
330
Frontier Agents (Kiro autonomous agent / AWS Security Agent / AWS DevOps Agent) の紹介
msysh
3
150
What happened to RubyGems and what can we learn?
mikemcquaid
0
250
学生・新卒・ジュニアから目指すSRE
hiroyaonoe
2
560
Featured
See All Featured
sira's awesome portfolio website redesign presentation
elsirapls
0
140
Everyday Curiosity
cassininazir
0
130
How STYLIGHT went responsive
nonsquared
100
6k
Amusing Abliteration
ianozsvald
0
96
A designer walks into a library…
pauljervisheath
210
24k
Documentation Writing (for coders)
carmenintech
77
5.2k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
450
Testing 201, or: Great Expectations
jmmastey
46
8k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
How to Think Like a Performance Engineer
csswizardry
28
2.4k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
34k
Building Adaptive Systems
keathley
44
2.9k
Transcript
Drew McLellan Perch CMS grabaperch.com -HOW WE WROTE A- TEMPLATE
ENGINE RDG Geek Night 10th September 2013
L I G H T W E I G H
T PHP CMS FOR SMALL WEBSITES
WE NEEDED A REALLY GOOD TEMPLATE LANGUAGE
-SO- W H A T W A S ALREADY OUT
THERE?
SMARTY (NOT SO SMART)
TWIG (NOT SO MATURE)
JUST PHP -WITH A- DIFFERENT S Y N T A
X
!<perch:content !!!type=”text” !!!id=”heading” !!!label=”Main heading” !!!required=”true” />
<h2><perch:content id="heading" type="text" label="Heading" required="true" title="true" /></h2> <p class="date"><perch:content id="date"
type="date" label="Date" format="%d %B %Y" /></p> <perch:content id="body" type="textarea" label="Body" textile="true" editor="markitup" required="true" />
HTML IS LIKE X M L RIGHT?
<img src="<perch:content id="photo" type="image" label="Photo" />" />
xkcd.com/208
stackoverflow.com/questions/1732348/
! <perch:content type=”text” ! ! id=”heading” label=”Main heading” ! !
required=”true” /> #<perch:content[^>]*/>#
$Tag = new PerchXMLTag( '<perch:content id="foo" bar="baz" />'); echo $Tag->bar;
// baz
#([a-z-]*)="([^"]*)"#
#([a-z-]+)=[\"]([^\"\\ \\]*(?:\\\\.[^\"\\\ \]*)*)[\"]#
-WAIT- REGULAR EXPRESSIONS ARE SLOW, RIGHT?
REGEX ARE SLOW UNLESS YOU NEED THEM
#(<perch:if[^>]*>)(((?! perch:if).)*)</perch:if># ! <perch:if exists=”foo”> ! ! ... loadsamarkup ...
! </perch:if>
-WE NEEDED- A NEW WAY -TO PARSE- TAG PAIRS
<perch:if exists=”a”> ! <perch:if exists=”b”> ! ! <perch:if exists=”c”> !
! ! Hello, world. ! ! </perch:if> ! </perch:if> <perch:else /> ! <perch:if exists=”d”> ! ! Goodbye, cruel world. ! </perch:if> </perch:if>
<perch:if exists=”a”> ! <perch:if exists=”b”> ! ! <perch:if exists=”c”> !
! ! Hello, world. ! ! </perch:if> ! </perch:if> <perch:else /> ! <perch:if exists=”d”> ! ! Goodbye, cruel world. ! </perch:if> </perch:if>
<perch:if exists=”a”> ! <perch:if exists=”b”> ! ! <perch:if exists=”c”> !
! ! Hello, world. ! ! </perch:if> ! </perch:if> <perch:else /> ! <perch:if exists=”d”> ! ! Goodbye, cruel world. ! </perch:if> </perch:if>
<perch:if exists=”a”> ! <perch:if exists=”b”> ! ! <perch:if exists=”c”> !
! ! Hello, world. ! ! </perch:if> ! </perch:if> <perch:else /> ! <perch:if exists=”d”> ! ! Goodbye, cruel world. ! </perch:if> </perch:if>
<perch:if exists=”a”> ! <perch:if exists=”b”> ! ! <perch:if exists=”c”> !
! ! Hello, world. ! ! </perch:if> ! </perch:if> <perch:else /> ! <perch:if exists=”d”> ! ! Goodbye, cruel world. ! </perch:if> </perch:if>
<perch:if exists=”a”> ! <perch:if exists=”b”> ! ! <perch:if exists=”c”> !
! ! Hello, world. ! ! </perch:if> ! </perch:if> <perch:else /> ! <perch:if exists=”d”> ! ! Goodbye, cruel world. ! </perch:if> </perch:if>
<perch:if exists=”a”> ! <perch:if exists=”b”> ! ! ! ! !
Hello, world. ! ! ! </perch:if> <perch:else /> ! <perch:if exists=”d”> ! ! Goodbye, cruel world. ! </perch:if> </perch:if>
<perch:if exists=”a”> ! <perch:if exists=”b”> ! ! ! ! !
Hello, world. ! ! ! </perch:if> <perch:else /> ! <perch:if exists=”d”> ! ! Goodbye, cruel world. ! </perch:if> </perch:if>
CLOSING TAGS -ARE - EASY
NO MORE WINDOWS CRASHES
MAYBE - WE WILL - REWRITE IT
THANK YOU Perch is at grabaperch.com On most things, I’
am @ drewm