From 06b30130173b4674142ee891088956742e8f00d1 Mon Sep 17 00:00:00 2001 From: Madhur Jain <21112002mj@gmail.com> Date: Thu, 5 Mar 2026 17:52:21 +0530 Subject: [PATCH 1/5] feat: implemented blocks in cta section pattern --- templates/_macros/vf_cta-section.jinja | 66 ++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/templates/_macros/vf_cta-section.jinja b/templates/_macros/vf_cta-section.jinja index 57314185e..62e2a2b3b 100644 --- a/templates/_macros/vf_cta-section.jinja +++ b/templates/_macros/vf_cta-section.jinja @@ -1,11 +1,15 @@ +{% from "_macros/shared/vf_cta-block.jinja" import vf_cta_block %} +{% from "_macros/shared/vf_description-block.jinja" import vf_description_block %} + # All Params # title_text: H2 title text # variant: variant for the cta section. Options are "default", "block". Default is "default". # layout: Layout type of cta section. Options are "100", "25-75". + # blocks: list of content blocks for the CTA section. Includes description and cta blocks. # All Slots - # description: Paragraph-style (one or more) content below the title. This slot is required for "cta-block-100" and "cta-block-25-75" layouts. - # cta: Call-to-action block with action links/buttons. This slot is required for "cta-block-100" and "cta-block-25-75" layouts. + # description (deprecated): Paragraph-style (one or more) content below the title. This slot is required for "cta-block-100" and "cta-block-25-75" layouts. + # cta (deprecated): Call-to-action block with action links/buttons. This slot is required for "cta-block-100" and "cta-block-25-75" layouts. # Variants: # default-100: Full-width CTA with title and link text @@ -14,6 +18,7 @@ # variant: default # layout: 100 # attrs: A dictionary of attributes to apply to the section element + # blocks: cta-block is required # Slots: # cta: The cta link - required @@ -23,6 +28,7 @@ # title_text: H2 title text - optional # variant: default # layout: 25-75 + # blocks: cta-block is required # Slots: # cta: The cta link - required @@ -32,6 +38,7 @@ # title_text: H2 title text - required # variant: block # layout: 100 + # blocks: cta-block is required # Slots: # description: Paragraph-style (one or more) content below the title - Optional @@ -42,31 +49,69 @@ # title_text: H2 title text - required # variant: block # layout: 25-75 + # blocks: cta-block is required # Slots: # description: Paragraph-style (one or more) content below the title - Optional # cta: Call-to-action block (required) -{%- macro vf_cta_section(title_text, variant='default', layout='100', caller=None, attrs={}) -%} +{%- macro vf_cta_section(title_text, variant='default', layout='100', caller=None, attrs={}, blocks=[]) -%} + + {%- set description_block = blocks | selectattr("type", "equalto", "description") | list | last | default(None) -%} + {%- set cta_block = blocks | selectattr("type", "equalto", "cta") | list | last | default(None) -%} + {% set description_content = caller('description') %} - {% set has_description = description_content|trim|length > 0 %} + {% set has_description = description_block or description_content|trim|length > 0 %} {% set cta_content = caller('cta') %} - {% set has_cta = cta_content|trim|length > 0 %} + {% set has_cta = cta_block or cta_content|trim|length > 0 %} + + {%- if cta_block -%} + {%- set cta_block_item = cta_block.get("item", {}) -%} + {%- set cta_block_type = cta_block_item.get("type","") | trim -%} + + {%- if cta_block_type == "html" -%} + {%- set cta_content = cta_block_item.get("content","") | trim -%} + {%- endif -%} + {%- endif -%} + + {%- if description_block -%} + {%- set description_block_item = description_block.get("item", {}) -%} + {%- endif -%} + {#- User can pass layout as "X-Y" or "X/Y" -#} {% set layout = layout | trim | replace('/', '-') %} + {% if layout not in ['100', '25-75'] %} {% set layout = "100" %} {% endif %} + {% set variant = variant | trim %} {% if variant not in ['default', 'block'] %} {% set variant = "default" %} {% endif %} + {%- macro _description_block() -%} - {% if has_description %}{{ description_content }}{% endif %} - {%- endmacro -%} + {%- if description_block -%} + {{ vf_description_block(type = description_block_item.get("type", ""), content = description_block_item.get("content","")) }} + {% elif has_description %} + {{ description_content }} + {% endif %} + {%- endmacro %} + {%- macro _cta_block() -%} - {% if has_cta -%}
{{ cta_content }}
{% endif %} - {%- endmacro -%} + {%- if cta_block -%} + {%- if cta_block_type == "html" -%} +
{{- cta_content | safe -}}
+ {%- else -%} + {{ vf_cta_block( primary=cta_block_item.get("primary", {}), + secondaries=cta_block_item.get("secondaries", []), + link=cta_block_item.get("link",{})) }} + {% endif %} + {% elif has_cta %} +
{{ cta_content }}
+ {% endif %} + {%- endmacro %} + {%- macro _cta_default_variant() -%}

{%- if title_text -%} @@ -76,11 +121,13 @@ {{ cta_content }}

{%- endmacro -%} + {%- macro _cta_block_variant() -%}

{{ title_text }}

{{ _description_block() -}} {{ _cta_block() }} {%- endmacro -%} + {%- macro _cta_variant() -%} {%- if variant == 'default' -%} {{ _cta_default_variant() }} @@ -88,6 +135,7 @@ {{ _cta_block_variant() }} {%- endif -%} {%- endmacro -%} +
Date: Thu, 5 Mar 2026 17:52:42 +0530 Subject: [PATCH 2/5] feat: updated examples of cta-section --- .../patterns/cta-section/block-25-75.html | 55 ++++++++++++++----- .../cta-section/block-full-width.html | 55 ++++++++++++++----- .../patterns/cta-section/cta-block.html | 41 ++++++++++++++ .../default-25-75-links-within-text.html | 24 ++++---- .../patterns/cta-section/default-25-75.html | 24 +++++--- .../default-full-width-links-within-text.html | 24 ++++---- .../cta-section/default-full-width.html | 26 +++++---- .../cta-section/description-block.html | 33 +++++++++++ 8 files changed, 215 insertions(+), 67 deletions(-) create mode 100644 templates/docs/examples/patterns/cta-section/cta-block.html create mode 100644 templates/docs/examples/patterns/cta-section/description-block.html diff --git a/templates/docs/examples/patterns/cta-section/block-25-75.html b/templates/docs/examples/patterns/cta-section/block-25-75.html index 2d36058de..a1c4787ba 100644 --- a/templates/docs/examples/patterns/cta-section/block-25-75.html +++ b/templates/docs/examples/patterns/cta-section/block-25-75.html @@ -4,18 +4,45 @@ {% block standalone_css %}patterns_all{% endblock %} {% set is_paper = true %} {% block content %} - {% call(slot) vf_cta_section( - title_text='The quick brown fox jumps over the lazy dog', - variant='block', - layout='25-75' - ) -%} - {%- if slot == 'description' -%} -

The quick brown fox jumps over the lazy dog.

- {%- endif -%} - {%- if slot == 'cta' -%} - Action - Action - Lorem ipsum dolor sit amet › - {%- endif -%} - {% endcall -%} + {% call(slot) vf_cta_section( + title_text='The quick brown fox jumps over the lazy dog', + variant='block', + layout='25-75', + blocks=[ + { + "type": "description", + "item": { + "type": "text", + "content": "The quick brown fox jumps over the lazy dog." + } + }, + { + "type": "cta", + "item": { + "primary": { + "content_html": "Action", + "attrs": { + "href": "link-url", + "class": "optional-css-class" + } + }, + "secondaries": [ + { + "content_html": "Secondary action", + "attrs": { + "href": "link-url" + } + } + ], + "link": { + "content_html": "Lorem ipsum dolor sit amet ›", + "attrs": { + "href": "link-url" + } + } + } + } + ] + ) -%} + {% endcall -%} {% endblock %} diff --git a/templates/docs/examples/patterns/cta-section/block-full-width.html b/templates/docs/examples/patterns/cta-section/block-full-width.html index 2f865041f..804271d66 100644 --- a/templates/docs/examples/patterns/cta-section/block-full-width.html +++ b/templates/docs/examples/patterns/cta-section/block-full-width.html @@ -4,18 +4,45 @@ {% block standalone_css %}patterns_all{% endblock %} {% set is_paper = true %} {% block content %} - {% call(slot) vf_cta_section( - title_text='The quick brown fox jumps over the lazy dog', - variant='block', - layout='100' - ) -%} - {%- if slot == 'description' -%} -

The quick brown fox jumps over the lazy dog.

- {%- endif -%} - {%- if slot == 'cta' -%} - Action - Action - Lorem ipsum dolor sit amet › - {%- endif -%} - {% endcall -%} + {% call(slot) vf_cta_section( + title_text='The quick brown fox jumps over the lazy dog', + variant='block', + layout='100', + blocks=[ + { + "type": "description", + "item": { + "type": "text", + "content": "The quick brown fox jumps over the lazy dog." + } + }, + { + "type": "cta", + "item": { + "primary": { + "content_html": "Action", + "attrs": { + "href": "link-url", + "class": "optional-css-class" + } + }, + "secondaries": [ + { + "content_html": "Action", + "attrs": { + "href": "link-url" + } + } + ], + "link": { + "content_html": "Lorem ipsum dolor sit amet ›", + "attrs": { + "href": "link-url" + } + } + } + } + ] + ) -%} + {% endcall -%} {% endblock %} diff --git a/templates/docs/examples/patterns/cta-section/cta-block.html b/templates/docs/examples/patterns/cta-section/cta-block.html new file mode 100644 index 000000000..1912183a8 --- /dev/null +++ b/templates/docs/examples/patterns/cta-section/cta-block.html @@ -0,0 +1,41 @@ +{% extends "_layouts/examples.html" %} +{% from "_macros/vf_cta-section.jinja" import vf_cta_section %} +{% block title %}CTA section / CTA block{% endblock %} +{% block standalone_css %}patterns_all{% endblock %} +{% set is_paper = true %} +{% block content %} + {% call(slot) vf_cta_section( + title_text='The quick brown fox jumps over the lazy dog', + variant='block', + layout='25-75', + blocks=[ + { + "type": "cta", + "item": { + "primary": { + "content_html": "Action", + "attrs": { + "href": "link-url", + "class": "optional-css-class" + } + }, + "secondaries": [ + { + "content_html": "Secondary action", + "attrs": { + "href": "link-url" + } + } + ], + "link": { + "content_html": "Lorem ipsum dolor sit amet ›", + "attrs": { + "href": "link-url" + } + } + } + } + ] + ) -%} + {% endcall -%} +{% endblock %} diff --git a/templates/docs/examples/patterns/cta-section/default-25-75-links-within-text.html b/templates/docs/examples/patterns/cta-section/default-25-75-links-within-text.html index 9f87b6ddb..e79c93274 100644 --- a/templates/docs/examples/patterns/cta-section/default-25-75-links-within-text.html +++ b/templates/docs/examples/patterns/cta-section/default-25-75-links-within-text.html @@ -4,14 +4,18 @@ {% block standalone_css %}patterns_all{% endblock %} {% set is_paper = true %} {% block content %} - {% call(slot) vf_cta_section( - variant='default', - layout='25/75', - ) -%} - {%- if slot == 'cta' -%} - For more information, read the docs -
- or contact us to let our experts help you take the next step - {%- endif -%} - {% endcall -%} + {% call(slot) vf_cta_section( + variant='default', + layout='25/75', + blocks=[ + { + "type": "cta", + "item": { + "type": "html", + "content": "For more information, read the docs
or contact us to let our experts help you take the next step" + } + } + ] + ) -%} + {% endcall -%} {% endblock %} diff --git a/templates/docs/examples/patterns/cta-section/default-25-75.html b/templates/docs/examples/patterns/cta-section/default-25-75.html index d2650e666..6fcf64086 100644 --- a/templates/docs/examples/patterns/cta-section/default-25-75.html +++ b/templates/docs/examples/patterns/cta-section/default-25-75.html @@ -4,13 +4,19 @@ {% block standalone_css %}patterns_all{% endblock %} {% set is_paper = true %} {% block content %} - {% call(slot) vf_cta_section( - title_text='The quick brown fox jumps over the lazy dog', - variant='default', - layout='25-75', - ) -%} - {%- if slot == 'cta' -%} - The quick brown fox jumps over the lazy dog › - {%- endif -%} - {% endcall -%} + {% call(slot) vf_cta_section( + title_text='The quick brown fox jumps over the lazy dog', + variant='default', + layout='25-75', + blocks=[ + { + "type": "cta", + "item": { + "type": "html", + "content": "The quick brown fox jumps over the lazy dog ›" + } + } + ] + ) -%} + {% endcall -%} {% endblock %} diff --git a/templates/docs/examples/patterns/cta-section/default-full-width-links-within-text.html b/templates/docs/examples/patterns/cta-section/default-full-width-links-within-text.html index acff1c813..93bcf4c33 100644 --- a/templates/docs/examples/patterns/cta-section/default-full-width-links-within-text.html +++ b/templates/docs/examples/patterns/cta-section/default-full-width-links-within-text.html @@ -4,14 +4,18 @@ {% block standalone_css %}patterns_all{% endblock %} {% set is_paper = true %} {% block content %} - {% call(slot) vf_cta_section( - variant='default', - layout='100', - ) -%} - {%- if slot == 'cta' -%} - For more information, read the docs -
- or contact us to let our experts help you take the next step - {%- endif -%} - {% endcall -%} + {% call(slot) vf_cta_section( + variant='default', + layout='100', + blocks=[ + { + "type": "cta", + "item": { + "type": "html", + "content": "For more information, read the docs
or contact us to let our experts help you take the next step" + } + } + ] + ) -%} + {% endcall -%} {% endblock %} diff --git a/templates/docs/examples/patterns/cta-section/default-full-width.html b/templates/docs/examples/patterns/cta-section/default-full-width.html index c3fe22724..1afb36228 100644 --- a/templates/docs/examples/patterns/cta-section/default-full-width.html +++ b/templates/docs/examples/patterns/cta-section/default-full-width.html @@ -4,14 +4,20 @@ {% block standalone_css %}patterns_all{% endblock %} {% set is_paper = true %} {% block content %} - {% call(slot) vf_cta_section( - title_text='The quick brown fox jumps over the lazy dog', - variant='default', - layout='100', - attrs={'id': 'full-width-default'} - ) -%} - {%- if slot == 'cta' -%} - The quick brown fox jumps over the lazy dog › - {%- endif -%} - {% endcall -%} + {% call(slot) vf_cta_section( + title_text='The quick brown fox jumps over the lazy dog', + variant='default', + layout='100', + attrs={'id': 'full-width-default'}, + blocks=[ + { + "type": "cta", + "item": { + "type": "html", + "content": "The quick brown fox jumps over the lazy dog ›" + } + } + ] + ) -%} + {% endcall -%} {% endblock %} diff --git a/templates/docs/examples/patterns/cta-section/description-block.html b/templates/docs/examples/patterns/cta-section/description-block.html new file mode 100644 index 000000000..c19ab1702 --- /dev/null +++ b/templates/docs/examples/patterns/cta-section/description-block.html @@ -0,0 +1,33 @@ +{% extends "_layouts/examples.html" %} +{% from "_macros/vf_cta-section.jinja" import vf_cta_section %} +{% block title %}CTA section / Description block{% endblock %} +{% block standalone_css %}patterns_all{% endblock %} +{% set is_paper = true %} +{% block content %} + {% call(slot) vf_cta_section( + title_text='The quick brown fox jumps over the lazy dog', + variant='block', + layout='25-75', + blocks=[ + { + "type": "description", + "item": { + "type": "text", + "content": "The quick brown fox jumps over the lazy dog." + } + }, + { + "type": "cta", + "item": { + "primary": { + "content_html": "Action", + "attrs": { + "href": "link-url" + } + } + } + } + ] + ) -%} + {% endcall -%} +{% endblock %} From df74484e3bb59013efa67d16b3ea8d7260282a7c Mon Sep 17 00:00:00 2001 From: Madhur Jain <21112002mj@gmail.com> Date: Thu, 5 Mar 2026 17:52:54 +0530 Subject: [PATCH 3/5] updated documentation for cta-section --- templates/docs/patterns/cta-section/index.md | 112 ++++++++++++++++++- 1 file changed, 109 insertions(+), 3 deletions(-) diff --git a/templates/docs/patterns/cta-section/index.md b/templates/docs/patterns/cta-section/index.md index 4f713e7ef..ded4bcac2 100644 --- a/templates/docs/patterns/cta-section/index.md +++ b/templates/docs/patterns/cta-section/index.md @@ -76,6 +76,94 @@ You can use block variant with 25-75 layout to create View example of the 25-75 split cta section with cta block +## Blocks + +### Description + +Description blocks can be used to display elaborative text content. + +By default, the description contents are rendered within a `

` tag, but you can also use `type:"html"` to render raw HTML +content. + +

+View example of the CTA section with description block +
+ +```json +{ + "type": "description", + "item": { + "type": "text" | "html", + "content": "Your content here" + } +} +``` + +- **`type`**: Either `"text"` (default) or `"html"`. Text content is wrapped in `

` tags, HTML content is rendered as-is. +- **`content`**: The text or HTML content to display. + +### CTA + +The CTA block allows you to include call-to-action elements within the section. +You may either use `type:"html"` with `content:""` to render custom HTML or use `type:"text"` which supports three types of CTA items: + +- **Primary**: 1 main call-to-action button +- **Secondary**: Supporting action buttons +- **Link**: Text link + +

+View example of the CTA section with CTA block +
+ +```json +{ + "type": "cta", + "item": { + "primary": { + "content_html": "Primary button text", + "attrs": { + "href": "link-url", + "class": "optional-css-class" + } + }, + "secondaries": [ + { + "content_html": "Secondary button text", + "attrs": { + "href": "link-url" + } + } + ], + "link": { + "content_html": "Link text", + "attrs": { + "href": "link-url" + } + } + } +} + +or + +{ + "type": "cta", + "item": { + "type": "html", + "content": "The quick brown fox jumps over the lazy dog ›" + + } +} +``` + +- **`primary`**: Optional primary button configuration. +- **`secondaries`**: Optional array of secondary button configurations. +- **`link`**: Optional text link configuration. + +Each of the CTA configurations accepts the following properties: + +- **`content_html`**: The inner HTML of the CTA item. +- **`attrs`**: Dictionary of button/link attributes. These are applied to the CTA element. If `href` is present, the CTA item will be an ``, otherwise it will be a `