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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
ClickHouseはどのように大規模データを活用したAIエージェントを全社展開しているのか
mikimatsumoto
0
190
M&A 後の統合をどう進めるか ─ ナレッジワーク × Poetics が実践した組織とシステムの融合
kworkdev
PRO
1
410
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
13k
Webhook best practices for rock solid and resilient deployments
glaforge
1
260
Bill One急成長の舞台裏 開発組織が直面した失敗と教訓
sansantech
PRO
1
300
Meshy Proプラン課金した
henjin0
0
250
仕様書駆動AI開発の実践: Issue→Skill→PRテンプレで 再現性を作る
knishioka
2
590
茨城の思い出を振り返る ~CDKのセキュリティを添えて~ / 20260201 Mitsutoshi Matsuo
shift_evolve
PRO
1
190
Oracle Cloud Observability and Management Platform - OCI 運用監視サービス概要 -
oracle4engineer
PRO
2
14k
システムのアラート調査をサポートするAI Agentの紹介/Introduction to an AI Agent for System Alert Investigation
taddy_919
2
1.9k
ファインディの横断SREがTakumi byGMOと取り組む、セキュリティと開発スピードの両立
rvirus0817
1
1.2k
データの整合性を保ちたいだけなんだ
shoheimitani
8
2.9k
Featured
See All Featured
Un-Boring Meetings
codingconduct
0
200
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
240
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
Reality Check: Gamification 10 Years Later
codingconduct
0
2k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Designing for humans not robots
tammielis
254
26k
Agile that works and the tools we love
rasmusluckow
331
21k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
52
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
300
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
90
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.3k
The SEO Collaboration Effect
kristinabergwall1
0
350
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