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
新人はどこまで自力でやり、どこからAIに頼るべきか/エンジニア育成に向き合う_先輩たちの悩みと知見共有会
toppan_digital_dev
1
620
A2UI for Android: Safely Rendering AI-Generated UI with Jetpack Compose - DroidKaigi 2026
itsmedreamwalker
0
140
How I Stole PSI from Android Studio - DroidKaigi2026
worker8
0
130
Building an Out-of-Order CPU
latte72
1
780
wkhtmltopdfの次どうするか問題2026
willnet
1
110
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
6
2.3k
Claude Codeを組織的に動かして月400PRを実現した話
happy_ryo
0
280
個人開発基盤をまるごとCloudflareに引っ越して爆速で総合的体験を向上させた話
tinykitten
0
190
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2k
Are APIs Still Relevant in the AI Era?
soyuka
0
230
What We Talk About When We Talk About XP
m_seki
2
630
TiDB Cloudのカスタムコントローラーによるオートスケール対応
takaidohigasi
0
120
Featured
See All Featured
SEO for Brand Visibility & Recognition
aleyda
0
4.7k
Designing for humans not robots
tammielis
254
26k
A Soul's Torment
seathinner
8
3.6k
Become a Pro
speakerdeck
PRO
31
6.3k
Into the Great Unknown - MozCon
thekraken
41
2.7k
Side Projects
sachag
456
43k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
500
Test your architecture with Archunit
thirion
2
2.4k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
Claude Code のすすめ
schroneko
67
230k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
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