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
180
Why Fast Matters
dafed
1
250
Leadership through Change
dafed
0
280
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
310
PHP Middleware i njegova upotreba
dafed
0
250
Asinhrone budućnosti i verteksi
dafed
0
310
Other Decks in Programming
See All in Programming
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
1
110
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
490
すこし踏み込む CancellationToken
htkym
2
1.7k
SREの越境 / SRE Collaboration
y0hgi
2
310
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
5.1k
Vue Fes Japan の “作る側”に関わってみて
naokihaba
0
150
Domain-Driven Transformation
hschwentner
2
2.3k
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.9k
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
7
13k
パーソナライズPodcastを作った話
repunit11
0
140
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.4k
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
410
Featured
See All Featured
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.4k
Making the Leap to Tech Lead
cromwellryan
135
10k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
340
The browser strikes back
jonoalderson
0
1.8k
Paper Plane (Part 1)
katiecoart
PRO
2
11k
The Pragmatic Product Professional
lauravandoore
37
7.5k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.9k
The World Runs on Bad Software
bkeepers
PRO
72
12k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
Building Applications with DynamoDB
mza
96
7.2k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.7k
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