Skip to content

Instantly share code, notes, and snippets.

@joelpittet
Created December 7, 2012 06:36
Show Gist options
  • Save joelpittet/4231241 to your computer and use it in GitHub Desktop.
Save joelpittet/4231241 to your computer and use it in GitHub Desktop.
<?php
// At top of template_preprocess_table function for test
$colgroups = array(
// COLGROUP with one COL element.
array(
'data' => array(
array(
'class' => array('test1-1'), // Attribute for the COL element.
),
array(
'class' => array('test1-2'), // Attribute for the COL element.
),
),
'class' => array('jazzy1'), // Attribute for the COLGROUP element.
),
// Colgroup with attributes and inner COL elements.
array(
'data' => array(
array(
'class' => array('test2-1'), // Attribute for the COL element.
),
array(
'class' => array('test2-2'), // Attribute for the COL element.
),
),
'class' => array('jazzy2'), // Attribute for the COLGROUP element.
),
);
?>
// IN table.html.twig
{% if colgroups %}
{% for colgroup in colgroups %}
{% if colgroup.cols %}
<colgroup{{ colgroup.attributes }}>
{% for i,col in colgroup.cols %}
<!-- {{ dump(col.attributes.class ) }} -->
<col{{ col.attributes }}/>
{% endfor %}
</colgroup>
{% else %}
<colgroup{{ colgroup.attributes }}/>
{% endif %}
{% endfor %}
{% endif %}
<colgroup class="jazzy1">
<!-- <pre class='xdebug-var-dump' dir='ltr'>
<b>object</b>(<i>Drupal\Core\Template\AttributeArray</i>)[<i>505</i>]
<i>protected</i> 'printed' <font color='#888a85'>=&gt;</font> <small>boolean</small> <font color='#75507b'>false</font>
<i>protected</i> 'value' <font color='#888a85'>=&gt;</font>
<b>array</b> <i>(size=1)</i>
0 <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'test1-1'</font> <i>(length=7)</i>
<i>protected</i> 'name' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'class'</font> <i>(length=5)</i>
</pre> -->
<col class="test1-1"/>
<!-- <pre class='xdebug-var-dump' dir='ltr'>
<b>object</b>(<i>Drupal\Core\Template\AttributeArray</i>)[<i>836</i>]
<i>protected</i> 'printed' <font color='#888a85'>=&gt;</font> <small>boolean</small> <font color='#75507b'>false</font>
<i>protected</i> 'value' <font color='#888a85'>=&gt;</font>
<b>array</b> <i>(size=1)</i>
0 <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'test1-2'</font> <i>(length=7)</i>
<i>protected</i> 'name' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'class'</font> <i>(length=5)</i>
</pre> -->
<col class="test1-2"/>
</colgroup>
<colgroup class="jazzy2">
<!-- <pre class='xdebug-var-dump' dir='ltr'>
<b>object</b>(<i>Drupal\Core\Template\AttributeArray</i>)[<i>282</i>]
<i>protected</i> 'printed' <font color='#888a85'>=&gt;</font> <small>boolean</small> <font color='#75507b'>false</font>
<i>protected</i> 'value' <font color='#888a85'>=&gt;</font>
<b>array</b> <i>(size=1)</i>
0 <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'test2-1'</font> <i>(length=7)</i>
<i>protected</i> 'name' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'class'</font> <i>(length=5)</i>
</pre> -->
<col/>
<!-- <pre class='xdebug-var-dump' dir='ltr'>
<b>object</b>(<i>Drupal\Core\Template\AttributeArray</i>)[<i>758</i>]
<i>protected</i> 'printed' <font color='#888a85'>=&gt;</font> <small>boolean</small> <font color='#75507b'>false</font>
<i>protected</i> 'value' <font color='#888a85'>=&gt;</font>
<b>array</b> <i>(size=1)</i>
0 <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'test2-2'</font> <i>(length=7)</i>
<i>protected</i> 'name' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'class'</font> <i>(length=5)</i>
</pre> -->
<col/>
</colgroup>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment