THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects &...
-
Upload
truongquynh -
Category
Documents
-
view
246 -
download
0
Transcript of THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects &...
![Page 1: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/1.jpg)
THE NEW THEME LAYERIN DRUPAL 8
Jen Lampton ~ @jenlamptonwww.jenlampton.com
Saturday, March 30, 2013
![Page 2: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/2.jpg)
WHY?
Saturday, March 30, 2013
![Page 3: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/3.jpg)
DRUPAL 7
Saturday, March 30, 2013
![Page 4: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/4.jpg)
DRUPAL 7: NEGATIVES
Saturday, March 30, 2013
![Page 5: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/5.jpg)
DRUPAL 7: NEGATIVE
Drupalism noun Something that only exists in Drupal.
•Drupal-specific template conventions
Saturday, March 30, 2013
![Page 6: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/6.jpg)
DRUPAL 7: NEGATIVE
Object or Array?
•Mixed data types (strings, objects & arrays)
Saturday, March 30, 2013
![Page 7: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/7.jpg)
DRUPAL 7: NEGATIVE
print or print render() ?
•Different methods of printing
Saturday, March 30, 2013
![Page 8: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/8.jpg)
DRUPAL 7: NEGATIVE
(because PHP is insecure)
PHPTemplate is insecure
Saturday, March 30, 2013
![Page 9: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/9.jpg)
NEGATIVE
Too many template files
Saturday, March 30, 2013
![Page 10: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/10.jpg)
Waaaaaaaaay too many theme functions
NEGATIVE
Saturday, March 30, 2013
![Page 11: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/11.jpg)
DRUPAL 7: NEGATIVE
too many complex of subsystems
Saturday, March 30, 2013
![Page 12: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/12.jpg)
DRUPAL 7: NEGATIVE
Satanic?
Saturday, March 30, 2013
![Page 13: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/13.jpg)
DRUPAL 7: NEGATIVE
Drupal 7 is too hard to learn!
Saturday, March 30, 2013
![Page 14: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/14.jpg)
THIS IS A LOT OF STUFF•Drupal-specific template conventions•Mixed data types (strings, objects & arrays)
$node->nid vs $content[‘links’]•Different methods of printing
print $node->nid vs print render($content[‘links’])•PHPTemplate is insecure•Two ways to override markup
Templates: *.tpl.php vs functions: theme_foo()•Many template files, many similar theme functions•Complex mix of subsystems•Difficult to learn for newcomers (and D6 veterans)
Saturday, March 30, 2013
![Page 15: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/15.jpg)
A NEW THEME LAYER?
Principals to guide us.BADCamp, 2012.
Saturday, March 30, 2013
![Page 16: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/16.jpg)
Principals to guide us
1. Start with nothingCore default markup should strive for semantic simplicity, with few HTML elements, added only as needed
A NEW THEME LAYER?
Saturday, March 30, 2013
![Page 17: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/17.jpg)
Principals to guide us
1. Start with nothing2. Build from use cases
Don't assume you know what people want or add features based on "What-if?" Think about the 90% of use cases.
A NEW THEME LAYER?
Saturday, March 30, 2013
![Page 18: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/18.jpg)
Principals to guide us
1. Start with nothing2. Build from use cases3. Provide tools
Give front-end experts a way to achieve specific goals; goals that apply to the remaining 10% of use cases. Keep in mind that complex problems may require complex solutions.
A NEW THEME LAYER?
Saturday, March 30, 2013
![Page 19: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/19.jpg)
Principals to guide us
1. Start with nothing2. Build from use cases3. Provide tools4. Consolidate
"Your markup is not special." Don't make something new. Work toward common theme functions that modules leverage (i.e. a Theme Component Library).
A NEW THEME LAYER?
Saturday, March 30, 2013
![Page 20: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/20.jpg)
Principals to guide us
1. Start with nothing2. Build from use cases3. Provide tools4. Consolidate5. Visibility
You should be able to see what's going on in a template without reading docs. Twig provides a lot of this by virtue of its syntax (it looks like HTML). Form follows function.
A NEW THEME LAYER?
Saturday, March 30, 2013
![Page 21: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/21.jpg)
Principals to guide us
1. Start with nothing2. Build from use cases3. Provide tools4. Consolidate5. Visibility6. Consistency
Do the same things everywhere, follow patterns. Use similar variable names across templates if they represent similar things.
A NEW THEME LAYER?
Saturday, March 30, 2013
![Page 22: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/22.jpg)
Principals to guide us
1. Start with nothing2. Build from use cases3. Provide tools4. Consolidate5. Visibility6. Consistency7. Don't dumb it down
Complexity should be reduced but not obscured. Themers *can* understand template logic and loops. When complexity does happen, use comments to explain why.
A NEW THEME LAYER?
Saturday, March 30, 2013
![Page 23: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/23.jpg)
Principals to guide us
1. Start with nothing2. Build from use cases3. Provide tools4. Consolidate5. Visibility6. Consistency7. Don't dumb it down8. Organization should be driven by meaning and semantics over technical convenience
Consider what an element means rather than how it structurally appears. Names and locations of templates should be self-evident. Themers want to see markup in templates, not abstraction.
A NEW THEME LAYER?
Saturday, March 30, 2013
![Page 24: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/24.jpg)
A NEW THEME LAYER?
Saturday, March 30, 2013
![Page 25: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/25.jpg)
TWIG
well documented
Saturday, March 30, 2013
![Page 26: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/26.jpg)
TWIG
extensible
Saturday, March 30, 2013
![Page 27: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/27.jpg)
TWIG
secure
Saturday, March 30, 2013
![Page 28: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/28.jpg)
TWIG
well-tested
Saturday, March 30, 2013
![Page 29: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/29.jpg)
TWIG
fast
Saturday, March 30, 2013
![Page 30: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/30.jpg)
TWIG
IDE integration
Saturday, March 30, 2013
![Page 31: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/31.jpg)
TWIG
recognizable syntax
Saturday, March 30, 2013
![Page 32: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/32.jpg)
TWIG
by Symfony’s author, Fabien Potencier
Saturday, March 30, 2013
![Page 33: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/33.jpg)
TWIGwhat does it look like?
Saturday, March 30, 2013
![Page 34: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/34.jpg)
what does it look like?
TWIG
Saturday, March 30, 2013
![Page 35: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/35.jpg)
print with {{ }}
TWIG
Saturday, March 30, 2013
![Page 36: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/36.jpg)
commands with {% %}
TWIG
Saturday, March 30, 2013
![Page 37: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/37.jpg)
comments with {# #}
TWIG
Saturday, March 30, 2013
![Page 38: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/38.jpg)
simple and intuitive
TWIG
Saturday, March 30, 2013
![Page 39: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/39.jpg)
A single way to override markup!
All theme functions become template files!
TWIG
Saturday, March 30, 2013
![Page 40: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/40.jpg)
less code than PHP tempates
TWIG
Saturday, March 30, 2013
![Page 41: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/41.jpg)
TWIG
D7
D8
theme_username becomes username.html.twig
less code than PHP tempates
Saturday, March 30, 2013
![Page 42: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/42.jpg)
TWIG
D7
D8
theme_image becomes image.html.twig
less code than PHP tempates
Saturday, March 30, 2013
![Page 43: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/43.jpg)
TWIG
D7
D8
theme_link becomes link.html.twig
less code than PHP tempates
Saturday, March 30, 2013
![Page 44: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/44.jpg)
TWIG
D7
D8
theme_item_list beomes item_list.html.twig
less code than PHP tempates
Saturday, March 30, 2013
![Page 45: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/45.jpg)
REMEMBER DRUPAL 7?•Drupal-specific template conventions•Mixed data types (strings, objects & arrays)
$node->nid vs $content[‘links’]•Different methods of printing
print $node->nid vs print render($content[‘links’])•PHPTemplate is insecure•Two ways to override markup
Templates: *.tpl.php vs functions: theme_foo()•Many template files, many similar theme functions•Complex mix of subsystems•Difficult to learn for newcomers (and D6 veterans)
Saturday, March 30, 2013
![Page 46: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/46.jpg)
REMEMBER DRUPAL 7?•Drupal-specific template conventions
Twig is used elsewhere on the web....is syntactically similar to other languages,
...and looks a lot more like HTML.
Saturday, March 30, 2013
![Page 47: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/47.jpg)
REMEMBER DRUPAL 7?•Drupal-specific template conventions FIXED•Mixed data types (strings, objects & arrays)
$node->nid vs $content[‘links’]All template variables are accessed consistently:
node.nidcontent.links
Saturday, March 30, 2013
![Page 48: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/48.jpg)
REMEMBER DRUPAL 7?•Drupal-specific template conventions FIXED•Mixed data types (strings, objects & arrays) FIXED
$node->nid vs $content[‘links’]•Different methods of printing
print $node->nid vs print render($content[‘links’])We’re removed calls to render() from templates:
{{ node.nid }}{{ content.links }}
Saturday, March 30, 2013
![Page 49: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/49.jpg)
REMEMBER DRUPAL 7?•Drupal-specific template conventions FIXED•Mixed data types (strings, objects & arrays) FIXED
$node->nid vs $content[‘links’]•Different methods of printing FIXED
print $node->nid vs print render($content[‘links’])•PHPTemplate is insecure
All variables will be *automatically* sanitized....and most PHP functions cannot be executed in
template files.
Saturday, March 30, 2013
![Page 50: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/50.jpg)
REMEMBER DRUPAL 7?•Drupal-specific template conventions FIXED•Mixed data types (strings, objects & arrays) FIXED
$node->nid vs $content[‘links’]•Different methods of printing FIXED
print $node->nid vs print render($content[‘links’])•PHPTemplate is insecure FIXED•Two ways to override markup
Templates: *.tpl.php vs functions: theme_foo()All theme functions are converted to
template filesnode.tpl.php becomes node.html.twig
theme_table() becomes table.html.twig
Saturday, March 30, 2013
![Page 51: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/51.jpg)
REMEMBER DRUPAL 7?•Drupal-specific template conventions FIXED•Mixed data types (strings, objects & arrays) FIXED
$node->nid vs $content[‘links’]•Different methods of printing FIXED
print $node->nid vs print render($content[‘links’])•PHPTemplate is insecure FIXED•Two ways to override markup FIXED
Templates: *.tpl.php vs functions: theme_foo()•Many template files, many similar theme functions
We’re working on this right now (Sprints!)
Saturday, March 30, 2013
![Page 52: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/52.jpg)
REMEMBER DRUPAL 7?•Drupal-specific template conventions FIXED•Mixed data types (strings, objects & arrays) FIXED
$node->nid vs $content[‘links’]•Different methods of printing FIXED
print $node->nid vs print render($content[‘links’])•PHPTemplate is insecure FIXED•Two ways to override markup FIXED
Templates: *.tpl.php vs functions: theme_foo()•Many template files, many similar theme functions @todo•Complex mix of subsystems
We can remove all theme functions, and potentially render, process & (maybe) preprocess.
Saturday, March 30, 2013
![Page 53: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/53.jpg)
remember the complexity of Drupal 7?
REMEMBER DRUPAL 7?
Saturday, March 30, 2013
![Page 54: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/54.jpg)
remove theme functions (and overrides) entirely.
REMEMBER DRUPAL 7?
Saturday, March 30, 2013
![Page 55: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/55.jpg)
remove process.
REMEMBER DRUPAL 7?
Saturday, March 30, 2013
![Page 56: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/56.jpg)
remove render.
REMEMBER DRUPAL 7?
Saturday, March 30, 2013
![Page 57: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/57.jpg)
remove page alter?
REMEMBER DRUPAL 7?
Saturday, March 30, 2013
![Page 58: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/58.jpg)
remove preprocess?
REMEMBER DRUPAL 7?
Saturday, March 30, 2013
![Page 59: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/59.jpg)
look what would happen in Drupal 8.
REMEMBER DRUPAL 7?
Saturday, March 30, 2013
![Page 60: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/60.jpg)
REMEMBER DRUPAL 7?•Drupal-specific template conventions FIXED•Mixed data types (strings, objects & arrays) FIXED
$node->nid vs $content[‘links’]•Different methods of printing FIXED
print $node->nid vs print render($content[‘links’])•PHPTemplate is insecure FIXED•Two ways to override markup FIXED
Templates: *.tpl.php vs functions: theme_foo()•Many template files, many similar theme functions @todo•Complex mix of subsystems @todo•Difficult to learn for newcomers (and D6 veterans)
Saturday, March 30, 2013
![Page 61: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/61.jpg)
REMEMBER DRUPAL 7?•Drupal-specific template conventions FIXED•Mixed data types (strings, objects & arrays) FIXED
$node->nid vs $content[‘links’]•Different methods of printing FIXED
print $node->nid vs print render($content[‘links’])•PHPTemplate is insecure FIXED•Two ways to override markup FIXED
Templates: *.tpl.php vs functions: theme_foo()•Many template files, many similar theme functions @todo•Complex mix of subsystems @todo•Difficult to learn for newcomers (and D6 veterans)
Consistency FTW
Saturday, March 30, 2013
![Page 62: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/62.jpg)
TWIG: OTHER WINS
Saturday, March 30, 2013
![Page 63: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/63.jpg)
•Twig template inheritance
TWIG: OTHER WINS
Saturday, March 30, 2013
![Page 64: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/64.jpg)
•Twig template inheritance
•Awesome variable inspection: Twig’s dpm()
TWIG: OTHER WINS
Saturday, March 30, 2013
![Page 65: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/65.jpg)
•Twig template inheritance
•Awesome variable inspection: Twig’s dpm()
•Templates are safe enough for in-browser editing
TWIG: OTHER WINS
Saturday, March 30, 2013
![Page 66: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/66.jpg)
•Twig template inheritance
•Awesome variable inspection: Twig’s dpm()
•Templates are safe enough for in-browser editing
•Possible performance gains: (much TBD) faster than render()?
TWIG: OTHER WINS
Saturday, March 30, 2013
![Page 67: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/67.jpg)
•Twig template inheritance
•Awesome variable inspection: Twig’s dpm()
•Templates are safe enough for in-browser editing
•Possible performance gains: (much TBD) faster than render()?
•2-way communication between UI and code: The UI can understand what variables exist (or not) in a template file
TWIG: OTHER WINS
Saturday, March 30, 2013
![Page 68: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/68.jpg)
QUESTIONS?
Saturday, March 30, 2013
![Page 69: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/69.jpg)
HOW CAN I HELP?
Saturday, March 30, 2013
![Page 70: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/70.jpg)
•Finish converting all existing core *.tpl.php files to Twig templates (sandbox) DONE~ISH•Finish converting all existing core theme functions to Twig templates (sandbox) DONE~ISH•Create & test patches for each module (core) HELP!•Help clean up markup in core (sandbox/core) HELP!•Consolidate similar templates (core) HELP!•Identify & enable template suggestions (core) HELP!•Rethink preprocess / __to_string() methods (maybe D9?)•Convert renderable arrays into Twig objects (maybe D9?)
•More TBD
NEXT TASKS
Saturday, March 30, 2013
![Page 71: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/71.jpg)
•Create & test patches for each module
live demo?
JUST DO IT!
Saturday, March 30, 2013
![Page 72: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/72.jpg)
A NEW THEME LAYERFOR DRUPAL 8
Saturday, March 30, 2013
![Page 73: THE NEW THEME LAYER IN DRUPAL 8 7: NEGATIVE Object or Array? •Mixed data types (strings, objects & arrays) Saturday, March 30, 2013 DRUPAL 7: NEGATIVE print or print render() ? •Different](https://reader031.fdocuments.net/reader031/viewer/2022022517/5b07d25b7f8b9a992a8b6f38/html5/thumbnails/73.jpg)
photo credits:lolcat-flexible
http://cheezburger.com/2679924736
anything is possible pebbleshttp://www.invergordontours.com/aip.html
lolcat questionmark http://icanhascheezburger.com/2007/10/31/11197/
wheel-reinventedhttp://www.brainwads.net/drewhawkins/2012/01/dont-re-invent-the-wheel-make-something-better/
objectshttp://2teachers1classroom.blogspot.com/2009_02_01_archive.html
shapeshttp://englishclass.jp/reading/topic/For_Screening_Purposes_Only
securehttp://blog.stratepedia.org/2010/06/03/what-is-a-secure-site/
consistencyhttp://icsigns.org/press/2010/03/23/consistency-staying-on-the-mark/
twig bird comichttp://s302.photobucket.com/albums/nn105/walkseva/?action=view¤t=thebirdneedsthattwig.gif¤ttag=bird%20park%20twig%20comic%20need%20it
twig docs screenshotshttp://twig.sensiolabs.org/documentation
twig speed graphshttp://phpcomparison.net/
python iconhttp://python-hosting.org/
ruby iconhttp://itmediaconnect.ro/en/web
django logohttp://py-arahat.blogspot.com/2010/08/django-vs-pylons.html
symfony logohttp://symfony.com/logo
scotch glasshttp://www.thespir.it/articles/scotch-101/?viewall=1
Saturday, March 30, 2013