A comfortable function that gives you performant flexibility to compile css-style-definitions at run-time.

Use this e.g. when rendering HTML-code for E-Mails.

 

{# MERGE #}
{% set styles = hublify.styles_merge( ... ) %}

 

Function

styles_merge(...)

Combines multiple css-style-definition-arrays into one.

Parameter: "<...>" A string containing the .....

Return: This functions returns a css-style-array.

{# Creating a standalone query-object #}
{% set myQueryObj = hublify.dataset('product') %}


From the source-code ...

/**
     * Generates a styles-array composed from optionally (multiple) merged style-definitions.
     *
     * Use this e.g. within twig-blocks for easily compile inline-css-styles based on dynamically
     * given "style-labels" (= $area, $template) and overrides (=$customStyles).
     *
     *
     * @param array $allStyles The standardized "global style-array" containing all possible sub-styles.
     *        Expected structure is:
     *        [style]
     *          [<$area>]
     *            [<tag>]
     *              [<style-attr>] - "<style value>"
     *
     *        [templates]
     *          [<$template>]
     *            [<tag>]
     *              [<style-attr>] - "<style value>"
     *
     *
     * @param string|null $area The main area-label used for: $allStyles[style][$area].
     *                    If is NULL no basic style is used.
     *
     * @param string|null $template An optional template-label used for: $allStyles[templates][$template].
     *                    Those defined style-attributes override the ones
     *                    defined from:  $allStyles[style][$area].
     *                    If is NULL nothing is merged from $allStyles[templates][].
     *
     * @param array|null $customStyles An optional custom style-attribute array.
     *                   If given this overrides all previously defined styles from $allStyles.
     *                   Expected array structure is:
     *                   [<tag>]
     *                     [<style-attr>] - "<style value>"
     *
     * @return array|null Returns on success a merged style-array of the structure:
     *                    [<tag>]
     *                      [<style-attr>] - "<style value>"
     *
     *                    In case of an error NULL is returned.
     *
     */

    function styles_merge(array $allStyles, string $area=null, string $template=null, array $customStyles=null): ?array