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
Uvod u TWIG - PHP template engine
Search
DaFED
August 16, 2013
Programming
0
120
Uvod u TWIG - PHP template engine
DaFED #13
Speaker: Dejan Dexter Duduković, Eton Digital
DaFED
August 16, 2013
Tweet
Share
More Decks by DaFED
See All by DaFED
A Storybook with Angular
dafed
0
190
Search & Destroy
dafed
0
130
Why Fast Matters
dafed
1
230
Leadership through Change
dafed
0
240
Upotreba VR tehnologija u real estate-u
dafed
0
270
Virtuelna Realnost uzvraća udarac
dafed
0
170
PHP i MongoDB iz prve ruke
dafed
0
290
PHP Middleware i njegova upotreba
dafed
0
210
Asinhrone budućnosti i verteksi
dafed
0
280
Other Decks in Programming
See All in Programming
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
4
2k
なぜSQLはAIぽく見えるのか/why does SQL look AI like
florets1
0
440
登壇資料を作る時に意識していること #登壇資料_findy
konifar
3
920
AIによる高速開発をどう制御するか? ガードレール設置で開発速度と品質を両立させたチームの事例
tonkotsuboy_com
6
1.9k
Rust 製のコードエディタ “Zed” を使ってみた
nearme_tech
PRO
0
140
16年目のピクシブ百科事典を支える最新の技術基盤 / The Modern Tech Stack Powering Pixiv Encyclopedia in its 16th Year
ahuglajbclajep
5
990
Vibe Coding - AI 驅動的軟體開發
mickyp100
0
170
AtCoder Conference 2025
shindannin
0
1k
Data-Centric Kaggle
isax1015
2
760
AI によるインシデント初動調査の自動化を行う AI インシデントコマンダーを作った話
azukiazusa1
1
680
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
380
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
250
Featured
See All Featured
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
440
BBQ
matthewcrist
89
10k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
320
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
64
Darren the Foodie - Storyboard
khoart
PRO
2
2.3k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
230
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
300
How to build a perfect <img>
jonoalderson
1
4.9k
Abbi's Birthday
coloredviolet
1
4.7k
My Coaching Mixtape
mlcsv
0
46
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
120
Transcript
PHP template engine Dejan Dexter Dudukovic Front-End developer EtonDigital
Tvorac twiga: Fabien Potencier ( Symfony ) Twig
je moderan templejt sistem za PHP Twig je – Fast , Flexible , Secure Sve sto vam treba je dokumentacija.
Symfony Drupal 8 ( in core )
CodeIgniter ( Spark , extension ) Zend ( extension ) Laravel Twig ( bundles ) Magento 2 WordPress ( plugin ) ……
Lako !!!! - Composer (recommended ) - Git –
( development version ) - PEAR package
Ucitavanje biblioteke: require_once 'vendor/twig/twig/lib/Twig/Autoloader.php'; Registrovanje loadera: Twig_Autoloader::register(); Kreiranje loader objekta
– ( folder za template fajlove ) $loader = new Twig_Loader_Filesystem('templates/'); Krairanje twig objekta i setovanje konfiguracije $twig = new Twig_Environment($loader , array( 'cache' => 'cache', // opcija za kesiranje stranica 'debug' => true // debug mode u development fazi ));
- Nadogradnja Twig funkcionalnosti kroz eksenzije $twig->addExtension( new Twig_Extension_Debug() );
- Dodavanje ( PHP funkcija u twig ) $twig->addFunction( new Twig_SimpleFunction('krumo', ‘tKrumo') );
Postoje 2 nacina za ucitavanje template fajlova. 1. Ucitavanje template
fajla sa prosledjenim varijablama ( promenjive ) I smestanje HTML,Twig koda u varijablu. $data['content'] = $twig->render('users.twig' , $user ); 2. Ucitavanje temlate fajla i prikazivanje na stranici ( zavrsni korak ) $twig->display( 'template.twig' , $data );
Variable: PHP: <?php echo $var ?> <?php echo htmlspecialchars($var, ENT_QUOTES,
'UTF-8') ?> Twig: {{ variable }} {{ variable|escape }} Funkcije i logike: {% funkcija() %} {% for user in users %} * {{ user.name }} {% else %} No user have been found. {% endfor %}
Tags ( macro , autoescape , extends , set
, include , filter ) Filters Functions ( date , dump , random ) Operators Test ( empty , even , null )
None