Client Side Template

{*endif}

Description

Closes a conditional command.

The {*endif} command closes a conditional section if it contains a {*if logicalExpression}, {*elseif logicalExpression}, and {*else}. For example, consider the following data in the Template Tester:

{
    employees: [
        {firstname: 'Fred', lastname: 'Smith', state: 'MA'},
        {firstname: 'Laura', lastname: 'Linneker', state: 'CA'},
        {firstname: 'Junior', lastname: 'Programmer', state: 'MA'},
        {firstname: 'Bill', lastname: 'Lindsey', state: 'NY'}
    ]
}

And say you have the following template with the different conditional commands.

{employees}
    Employee name: {firstname}{lastname}<br>
    <div>
        {*if state=='MA'}
            Employee is based in MA
        {*elseif state=='CA'}
            Employee is based in CA
        {*else}
            Employee is not based in MA or CA
        {*endif}
    </div><br>
{/employees}

This returns the following results:

Employee name: FredSmith
Employee is based in MA

Employee name: LauraLinneker
Employee is based in CA

Employee name: JuniorProgrammer
Employee is based in MA

Employee name: BillLindsey
Employee is not based in MA or CA

Without the {*else} statement the template would look like this:

{employees}
    Employee name: {firstname}{lastname}<br>
    <div>
        {*if state=='MA'}
            Employee is based in MA
        {*elseif state=='CA'}
            Employee is based in CA
        {*else}
            Employee is not based in MA or CA
    </div><br>
{/employees}

And return a result that doesn't actually execute the conditional commands but, rather, treats them like a regular string.

Employee name: FredSmith
{*if state=='MA'} Employee is based in MA {*elseif state=='CA'} Employee is based in CA {*else} Employee is not based in MA or CA

Employee name: LauraLinneker
{*if state=='MA'} Employee is based in MA {*elseif state=='CA'} Employee is based in CA {*else} Employee is not based in MA or CA

Employee name: JuniorProgrammer
{*if state=='MA'} Employee is based in MA {*elseif state=='CA'} Employee is based in CA {*else} Employee is not based in MA or CA

Employee name: BillLindsey
{*if state=='MA'} Employee is based in MA {*elseif state=='CA'} Employee is based in CA {*else} Employee is not based in MA or CA