Conditional Logic in Emails HTML Block

# Feature Request: Conditional Logic Tags for HTML Email Blocks ## Summary Add conditional logic tags to Flowmattic's email feature to enable dynamic inclusion/exclusion of HTML content based on field values and conditions. ## Problem Statement Currently, when using HTML blocks in emails, all content is static and displayed regardless of the underlying data. This creates verbose emails with empty sections or irrelevant information when certain fields are empty or don't meet specific criteria. ## Proposed Solution Implement conditional logic tags that allow users to wrap HTML content with conditions, similar to template engines. This would enable dynamic email generation based on data values. ### Suggested Syntax {{if:field_name:condition:value}} <!-- HTML content to show when condition is met --> {{end_if:field_name}} ### Basic Example {{if:auto_approval:eq:true}} [TABLE_ROW] [CELL]Status:[/CELL] [CELL]Auto-approved[/CELL] [/TABLE_ROW] {{end_if:auto_approval}} ### Nested Conditional Example {{if:member:eq:true}} [HEADING]Member Information:[/HEADING] [DIV class="member-details"] {{if:member_name:isNotEmpty}} [PARAGRAPH][STRONG]Name:[/STRONG] {{member_name}}[/PARAGRAPH] {{end_if:member_name}} {{if:member_tier:eq:premium}} [PARAGRAPH][EMPHASIS]Premium Member Benefits Apply[/EMPHASIS][/PARAGRAPH] {{end_if:member_tier}} [/DIV] {{end_if:member}} ## Supported Conditions - `eq` (equals) - `neq` (not equals) - `isEmpty` (field is empty) - `isNotEmpty` (field has content) - `gt` (greater than) - `lt` (less than) - `contains` (contains text) ## Use Cases - **Dynamic Reports**: Include table rows only when data exists - **Conditional Messaging**: Show different content for different user types - **Contract Generation**: Display clauses based on agreement terms - **Personalized Communications**: Tailor content to recipient attributes ## Benefits - Cleaner, more professional emails - Reduced content bloat - Enhanced personalization capabilities - Better user experience for email recipients - Simplified template management ## Reference Implementation This functionality is successfully implemented in Formidable Forms, demonstrating its practical value for creating complex, contract-like email outputs. ## Technical Considerations - Should support unlimited nesting levels - Requires proper parsing to handle malformed tags gracefully - Consider performance impact on email generation - Maintain backward compatibility with existing templates

Menu Mag posted 15 days ago

Discussion