I'm making a review widget that comes as a shortcode and Gutenberg block. The shortcode part was easy as I have built many shortcodes before, but I'm stuck on building my first Gutenberg block.
More specifically, I've learned how to build a block that outputs div with custom class, but I can't find how to add a custom div attribute anywhere...
Here's the code responsible for block output:
return el( 'div',
{
className: 'review-widget',
}
); // End return
and this outputs
<div class="review-widget"></div>
properly.
However, I need to output a div like this:
<div class="review-widget" data-limit="10"></div>
but I'm having a hard time adding the data-limit="10" to the div.
I've tried:
return el( 'div',
{
className: 'review-widget',
data-limit: 10
}
); // End return
but it doesn't work...
Any ideas would be appreciated :)