WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\BlockTypes

AbstractBlock::get_html_data_attributes() protected WC 1.0

Converts block attributes to HTML data attributes.

{} It's a method of the class: AbstractBlock{}

No Hooks.

Return

String. Rendered HTML attributes.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_html_data_attributes( $attributes );
$attributes(array) (required)
Key value pairs of attributes.

Code of AbstractBlock::get_html_data_attributes() WC 5.7.1

protected function get_html_data_attributes( array $attributes ) {
	$data = [];

	foreach ( $attributes as $key => $value ) {
		if ( is_bool( $value ) ) {
			$value = $value ? 'true' : 'false';
		}
		if ( ! is_scalar( $value ) ) {
			$value = wp_json_encode( $value );
		}
		$data[] = 'data-' . esc_attr( strtolower( preg_replace( '/(?<!\ )[A-Z]/', '-$0', $key ) ) ) . '="' . esc_attr( $value ) . '"';
	}

	return implode( ' ', $data );
}