Skip to content

Conversation

@Nayab-Gauhar
Copy link

Extract duplicated code blocks into private helper macros to improve maintainability.

Created two private helper macros:

  • _vf_tiered_list_item_separator(): Renders the HR separator between list items
  • _vf_tiered_list_item(): Renders list item content with parameterized column classes

This eliminates code duplication while maintaining the exact same functionality.

Fixes #5530

Done

  • Extracted HR separator block into _vf_tiered_list_item_separator() macro
  • Extracted list item content block into _vf_tiered_list_item() macro with parameterized column classes
  • Replaced duplicated code blocks with macro calls
  • Verified that functionality remains unchanged

QA

  • The changes are purely structural/refactoring - no visual or functional changes
  • All existing tiered list examples should continue to work exactly as before
  • The macro API remains unchanged

Check if PR is ready for release

  • PR should have one of the following labels: Maintenance 🔨 (suggested for this refactoring)
  • Vanilla version in package.json should be updated (this is a maintenance/refactoring change, so a bugfix release x.x.X would be appropriate)
  • No changes to component class names or macro APIs, so no updates needed to what's new page

Extract duplicated code blocks into private helper macros to improve maintainability.

Created two private helper macros:
- _vf_tiered_list_item_separator(): Renders the HR separator between list items
- _vf_tiered_list_item(): Renders list item content with parameterized column classes

This eliminates code duplication while maintaining the exact same functionality.

Fixes canonical#5530
@webteam-app
Copy link

Nayab-Gauhar is not a collaborator of the repo

@jmuzina jmuzina requested review from Copilot and jmuzina October 31, 2025 16:01
@jmuzina jmuzina changed the title Refactor tiered list macro to extract duplicated code blocks chore(Tiered List): Refactor tiered list macro to extract duplicated code blocks Oct 31, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the vf_tiered_list Jinja macro by extracting repeated list item rendering logic into reusable helper macros, improving code maintainability and reducing duplication.

Key changes:

  • Introduced two private helper macros (_vf_tiered_list_item_separator and _vf_tiered_list_item) to encapsulate repeated HTML structure
  • Replaced duplicated list item rendering code with calls to the new helper macros
  • Cleaned up formatting by removing extra blank lines and standardizing self-closing HR tags

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +25 to +26
<div class="{{ title_col_classes }}">{{ title_content }}</div>
<div class="{{ description_col_classes }}">{{ description_content }}</div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: can we only add the class attributes here if the class parameters are defined and have length > 0?

@jmuzina jmuzina added Review: Percy needed This PR needs a review of Percy for visual regressions and removed Review: Percy +1 labels Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tiered list: Extract tiered list item blocks

3 participants