Dynamicallly add attribute to top level element of component
Use Case:
I'm trying to implement bootstrap like row's and columns where the rows component can have column components as childs. The column component dialog should be able to have dynamic width sizes set by the author (25%, 33%, 50%).
Problem:
In order for me to dynamically set the column width's I would have to add it to the top level element (div class='column') but I'm not sure how to do this.
HTML for my ROW component:
<div class="row">
<sly data-sly-resource="${'row-parsys' @ resourceType='wcm/foundation/components/parsys'}"></sly>
</div>
HTML for my COLUMN component:
<sly data-sly-resource="${'col-parsys' @ resourceType='wcm/foundation/components/parsys'}">
</sly>
Code generated in the DOM when I add column within row component parsys:
<div class="row">
<div class="column"></div>
<div class="column"></div>
</div>
How can I dynamically pass in column widths to the column component div so it looks like this:
<div class='row'>
<div style='width: 25%;' class='column'></div>
<div style='width: 50%;' class='column'></div>
</div>
The only other solution I can think of is have multiple column components with set sizes. I would like to do this with one component which can be authored to different sizes.