# Render Element content

Basic Structure<br>

The layout file should be a PHP template that renders your element's HTML. Here's the basic structure:

Important Notes

* Security:
  * Always use `defined('ABSPATH') || exit`;
  * Escape all output using appropriate functions
  * Sanitize all input data
* Styling:
  * Use `TemplateHelpers::get_style()` for consistent styling
  * Use `TemplateHelpers::get_spacing_value()` for padding/margin
  * Use `TemplateHelpers::get_font_family_value()` for fonts
* Content Processing:
  * Use `do_shortcode()` for shortcode processing
  * Use `yaymail_kses_post()` for HTML content
  * Use output buffering for complex HTML structures

<pre class="language-php"><code class="lang-php">&#x3C;?php

<strong>defined('ABSPATH') || exit;
</strong><strong>
</strong>use YayMail\Utils\TemplateHelpers;

if (empty($args['element'])) {
    return;
}

$element = $args['element'];
$data    = $element['data'];

// Define styles
$wrapper_style = TemplateHelpers::get_style( [
    'word-break'       => 'break-word',
    'background-color' => $data['background_color'] ?? '#fff',
    'padding'          => TemplateHelpers::get_spacing_value( $data['padding'] ?? [] ),
] );

$title_style = TemplateHelpers::get_style( [
    'text-align'    => yaymail_get_text_align(),
    'color'         => $data['title_color'] ?? 'inherit',
    'margin-bottom' => '10px',
    'font-size'     => '18px',
    'font-weight'   => 'bold',
    'font-family'   => TemplateHelpers::get_font_family_value( $data['font_family'] ?? 'inherit'),
] );

// Process content
$title = isset( $data['title'] ) ? do_shortcode( $data['title'] ) : '';
$content = isset( $data['rich_text'] ) ? do_shortcode( $data['rich_text'] ) : '';

// Build HTML
ob_start();
?>
&#x3C;div class="your-element">
    &#x3C;h2 style="&#x3C;?php echo esc_attr( $title_style ); ?>">
        &#x3C;?php echo yaymail_kses_post( $title ); ?>
    &#x3C;/h2>
    &#x3C;div class="content">
        &#x3C;?php echo yaymail_kses_post( $content ); ?>
    &#x3C;/div>
&#x3C;/div>
&#x3C;?php
$element_content = ob_get_clean();

// Wrap and output
TemplateHelpers::wrap_element_content( $element_content, $element, $wrapper_style );
</code></pre>
