I'm developing a custom block in Drupal 8. In my
build() method I've got:
$progress_markup = array( '#theme' => 'progress_bar', '#percentage' => $registration_percentage, '#message' => array('#markup' => $registration_node_count . ' of ' . $this->configuration['capacity']), ); $markup = \Drupal::theme()->render('progress_bar', $progress_markup);
This generates the following HTML:
<div class="progress" data-drupal-progress> <div class="progress__track"><div class="progress__bar" style="width: %"></div></div> <div class="progress__percentage">%</div> <div class="progress__description">30 of 120</div> </div>
However, when the block renders on the page, the
style attribute has been removed. Here's the relevant D8 issue.
What I don't understand is: if I create a custom block and use Full HTML, and paste in the generated markup that contains the
style attribute, Drupal 8 will happily render it. But when I generate this markup in the
build() method, it gets removed.
Is there a way to specify, in the block plugin definition, that the
build() method should not filter out any HTML? Any other thoughts on how ot get around this issue?