Automattic\WooCommerce\Blocks\BlockTypes
EmailContent::render_preview
Renders the block preview for the editor.
Method of the class: EmailContent{}
No Hooks.
Returns
String. Rendered block output.
Usage
// protected - for code of main (parent) or child class $result = $this->render_preview( $attributes );
- $attributes(array) (required)
- Block attributes.
EmailContent::render_preview() EmailContent::render preview code WC 10.3.6
protected function render_preview( $attributes ) {
/**
* Email preview instance for rendering dummy content.
*
* @var EmailPreview $email_preview - email preview instance
*/
$email_preview = wc_get_container()->get( EmailPreview::class );
$type_param = EmailPreview::DEFAULT_EMAIL_TYPE;
if ( isset( $attributes['emailType'] ) ) {
$type_param = sanitize_text_field( wp_unslash( $attributes['emailType'] ) );
}
try {
return $email_preview->generate_placeholder_content( $type_param );
} catch ( \Exception $e ) {
// Catch other potential errors during content generation.
return esc_html__( 'There was an error rendering the email preview.', 'woocommerce' );
}
}