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
Drew McLellan
September 10, 2013
Technology
0
220
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
130
HTML5 APIs Confoo Montreal
drewm
1
200
PHP Payments with Omnipay
drewm
0
96
HTML5 APIs Confoo Vancouver
drewm
0
230
Learn to Love Regular Expressions
drewm
0
94
Ecommerce Projects with Moltin
drewm
0
670
Writing Portable PHP
drewm
0
94
Getting to Grips with Regular Expressions
drewm
1
240
Back to Front Performance - Oct 2013
drewm
0
120
Other Decks in Technology
See All in Technology
目標設定は好きですか? アジャイルとともに目標と向き合い続ける方法 / Do you like target Management?
kakehashi
10
3k
Luupの開発組織におけるインシデントマネジメントの変遷 ver.RoadtoSRENEXT2024
grimoh
1
270
Flutter研修【MIXI 24新卒技術研修】
mixi_engineers
PRO
0
160
可視化プラットフォームGrafanaの基本と活用方法の全て
hamadakoji
0
230
データベース研修 DB基礎【MIXI 24新卒技術研修】
mixi_engineers
PRO
0
210
VPoEの視点から見た、ヘンリーがサーバーサイドKotlinを使う理由 / Why Server-side Kotlin 2024
cho0o0
1
420
【基調講演】変える、今ここから ― IoTとAIで紡ぐ未来
soracom
PRO
0
320
What is DRE? - Road to SRE NEXT@広島
chanyou0311
3
630
Docker互換のセキュアなコンテナ実行環境「Podman」超入門
devops_vtj
6
3.2k
AWS IAMのアンチパターン/AWSが考える最低権限実現へのアプローチ概略(JAWS-UG朝会#59資料改修20分版)
htan
0
330
簡単に始めるSnowflakeの機械学習
nayuts
1
190
エンジニアの生存戦略 〜クラウド潮流の経験から紐解く技術トレンドのメカニズムと乗りこなし方〜
shimy
9
1.9k
Featured
See All Featured
Visualization
eitanlees
139
14k
Documentation Writing (for coders)
carmenintech
63
4.2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
228
16k
What’s in a name? Adding method to the madness
productmarketing
PRO
21
2.9k
Creatively Recalculating Your Daily Design Routine
revolveconf
214
11k
Building Effective Engineering Teams - LeadDev
addyosmani
47
2.2k
Building a Scalable Design System with Sketch
lauravandoore
458
32k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
360
22k
Imperfection Machines: The Place of Print at Facebook
scottboms
262
13k
What's new in Ruby 2.0
geeforr
338
31k
Raft: Consensus for Rubyists
vanstee
134
6.5k
Large-scale JavaScript Application Architecture
addyosmani
506
110k
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