Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Uvod u TWIG - PHP template engine
Search
DaFED
August 16, 2013
Programming
120
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Uvod u TWIG - PHP template engine
DaFED #13
Speaker: Dejan Dexter Duduković, Eton Digital
DaFED
August 16, 2013
More Decks by DaFED
See All by DaFED
A Storybook with Angular
dafed
0
220
Search & Destroy
dafed
0
170
Why Fast Matters
dafed
1
250
Leadership through Change
dafed
0
280
Upotreba VR tehnologija u real estate-u
dafed
0
310
Virtuelna Realnost uzvraća udarac
dafed
0
200
PHP i MongoDB iz prve ruke
dafed
0
310
PHP Middleware i njegova upotreba
dafed
0
240
Asinhrone budućnosti i verteksi
dafed
0
300
Other Decks in Programming
See All in Programming
Vibes Containers 〜AIで変わるコンテナ設計と運用〜
tkikuc
3
540
Intent as Code
shoppingjaws
6
1k
【高い買い物LT会】初任給で話題の国産フィジカルAIを買った話
akagami
PRO
0
160
自分的「カンファレンスの楽しみ方」
syumai
0
200
そのリトライ、死んだコネクションを使い回していませんか ── GoのHTTPクライアントとHTTP/2を実プロダクト障害から学び直す
myus4a
0
130
Can LLMs Replicate 4 Years of Compose Migration? Exploring the boundaries of automation with 279 XML files from a real product
makun
0
140
AWS Step Functions 大規模並列の壁を越える / jaws-sonic-2026-niigata-step-functions
kasacchiful
PRO
1
450
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
7
2.9k
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
560
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
100
変化を抱擁するドキュメントの作り方 - ビジネスルール駆動開発がもたらす、コードとの新しい関係
ioki
2
200
How I Stole PSI from Android Studio - DroidKaigi2026
worker8
0
120
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
Optimizing for Happiness
mojombo
378
71k
A designer walks into a library…
pauljervisheath
211
25k
Paper Plane (Part 1)
katiecoart
PRO
2
11k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
460
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
Crafting Experiences
bethany
1
330
We Are The Robots
honzajavorek
0
370
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