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
130
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
Transcript
10 slides
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
More Decks by DaFED
See All by DaFED
A Storybook with Angular
dafed
0
220
Search & Destroy
dafed
0
190
Why Fast Matters
dafed
1
260
Leadership through Change
dafed
0
290
Upotreba VR tehnologija u real estate-u
dafed
0
320
Virtuelna Realnost uzvraća udarac
dafed
0
210
PHP i MongoDB iz prve ruke
dafed
0
320
PHP Middleware i njegova upotreba
dafed
0
250
Asinhrone budućnosti i verteksi
dafed
0
310
Other Decks in Programming
See All in Programming
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
5
910
Kotlin JVM用に作られたライブラリのKMPを前提とした再設計
jsoizo
0
130
仕様駆動開発入門 (何を作るかを先に決めて渡す) | 目指せ Kiro マスター 05
inariku
PRO
2
180
Python Lambdaにおけるテストしやすい設計とAI支援の活用 / Designing Testable Python Lambda Functions with AI
kitano_yuichi
1
340
自宅サーバはどこまで再現できるのか - Proxmox VE上のVM環境をIaCとバックアップで戻してみた
youto
0
420
우리의 Nitro Modules는 당신의 Turbo Modules보다 아름답다
l2hyunwoo
0
270
Zero-Tap Sign-In対応、結局何をすればいいの?
mitohato14
0
2.3k
느린 네트워크와 저사양 디바이스 사용자를 위한 웹뷰 로딩 시간 개선기
kmkim
1
240
ローカルLLMの基本と近況 2611 / Local LLM basics and recent situation 2611
kishida
3
560
ビジネスロジックを堅牢に~Scala 3のドメインプリミティブ~
j5ik2o
0
200
AI Augmentation Techniques with Liberty
ivargrimstad
1
510
社内AIエージェント「Askワンバン」における コストチューニングの取り組み
t0yohei
0
170
Featured
See All Featured
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
How to build a perfect <img>
jonoalderson
1
6.2k
Prompt Engineering for Job Search
mfonobong
0
590
Between Models and Reality
mayunak
4
590
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
60k
Navigating Team Friction
lara
192
16k
Ruling the World: When Life Gets Gamed
codingconduct
0
440
Documentation Writing (for coders)
carmenintech
77
5.6k
AI: The stuff that nobody shows you
jnunemaker
PRO
12
1.3k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
2
2.1k
Site-Speed That Sticks
csswizardry
13
1.6k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k