Gotta make a move to a theme system that's right for me.
Components keep me movin', keep me groovin' with some energy.
At MidCamp we talked about it, talked about it,
talked about it it, talked about it,
At Drupal Con talked about, talked about,
Talked about design components.
Gotta move on,
From data-model templates,
Gotta move on,
From style guide markup duplication,
Gotta move on
A-won't you take me to... Chunky Town?
Won't you take me to... Chunky Town.
Won't you take me to... Chunky Town?
Won't you take me to... Chunky Town.
Chunks,
Mega Chunks,
Chunks,
Super Chunks,
Chunks,
Inside Chunks.
Won't you take me to... Chunky Town?
At DrupalCon New Orleans, Dries Buytaert mentioned component-based theming as a potential future initiative for Drupal. This idea had been discussed at MidCamp, and further hashed out at DrupalCon. Some initial efforts have been made to prototype how we could get started with real component-based markup in Drupal theming.
Currently, Drupal's theme system consists primarily of templates that are tightly tied to Drupal's data structures. While much of front-end development revolves around design components—breaking a design into smaller and smaller chunks—it can often take several template overrides to create the markup for one component. That causes difficulties in integrating Drupal with style guides or pattern libraries based around components, such as Pattern Lab or KSSNode. Markup often needs to be duplicated, once in Drupal's templates, and again in the templates that drive a style guide.
Moving Drupal to a theme system based around components could have numerous benefits, from improving style guide integration to making it easier for site builders to build sites outside-in to making it easier to reuse templates both server-side and client-side.
In this session we'll discuss why component-based theming matters, the current state of this discussion, and how you can help take Drupal's theme system to Chunk-y Town.
75. T E M P L A T E S G A L O R E
Multiple templates per component
node--teaser--event
field--image--event
image--event
field--tags--event
76. A N A L O G Y A L E RT
Base styles vs BEM components
77. A N A L O G Y A L E RT
Base templates vs template suggestions
78. A N A L O G Y A L E RT
As overrides increase, value of base decreases
79. D I S C O I N F E R N O
Burn the mother down
Components
off the island
Trouble getting
80. D R I L L A B I L I T Y
One template per component
81. I T E M C O M P O N E N T S
Includes Data Series with Data Items
Tag list heading
Article Teaser
Tag Tag
82. I T E M C O M P O N E N T S
Separate templates for Data Series and Items?
83. I T E M C O M P O N E N T S
One template: use Data Series/Items attributes?
<div class=“tags”>
<h2 class=“tags__heading”>{{ tags.heading }}</h2>
<ul {{ tags.Attributes.addClass(‘tags__list’ }}>
{% for tag in tags %}
<li {{ tag.Attributes.addClass(‘tags__item’ }}>
<a class=“tags__item-link” href=“{{ tag.link }}”>
{{ tag.text }}
</a>
</li>
{% endfor %}
</ul>
</div>
84. P R E S E N T E R S
Replacing preprocess functions
85. P R E P RO C E S S
Raw data > Template variables
87. T W I G P R E S E N T E R S
Raw data > Template variables
88. T W I G P R E S E N T E R
Presenter
Logic
Component
Markup
Raw data
89. E X T E N S I B I L I T Y ?
Modules, themes register mini-presenters?
90. E X T E N S I B I L I T Y ?
Include mini-presenters in main presenter?
Presenter
Mini-presenter
Mini-presenter
Mini-presenter
91. C H I L D C O M P O N E N T S
Self-rendering arrays vs. includes
92. R E N D E R A R R A Y S
Giant arrays of data: loads of context!
93. R E N D E R A R R A Y S
Decide how to render themselves
94. R E N D E R A R R A Y S
Pick their template from suggestions
95. R E N D E R A R R A Y S
Contain arbitrary elements
96. E X P L I C I T I N C L U D E S
Specify template and pass in variables
97. T W I G B L O C K S ?
Wrap render array variable in block?
{%block content %}
{{ content }}
{% endblock
98. T W I G B L O C K S ?
External sources: explicitly include templates
{%block content %}
{{ include(’field’, {heading: ‘Tags’}) }}
{{ include(’field’, {heading: ‘Image’}) }}
{{ include(’field’, {heading: ‘CTA’}) }}
{% endblock
99. C O N F L I C T
Frameworks, style guides don’t have site builders
100. C O N F L I C T
Site builder flexibility strength of Drupal
101. A T T R I B U T E S
Unique Drupal data structures
102. T W I G E X T E N S I O N S
Replicate outside Drupal?