#if, #elseif and #else


#if, #elseif and #else statements can be used in templates to define "if this, then that" type scenarios.

Data markers are used within these to produce conditional content based on information saved to the matter or contact.

For further guidance on configuring the #if helper, watch our short training video!

#if

Can be used to output a statement based on information saved to a data marker.

Example

Output

{{#if property.tenure}}

Thank you for providing us with the tenure details...

{{#endif}}

Acts in a true or false manner.

If the data marker property.tenure has a value saved against it, the defined statement will be outputted.

If the data marker is empty or set to the words "false" or "no" , the statement will be ignored.

#if statements always need to end with an #endif.

Within #if statements, the following conditions are treated as true:

  • The word "true"
  • The word "yes"
  • A string of 1 or more characters, except the words "false" or "no"
  • A list containing at least 1 item, when using the #foreach helper
  • The value "0"

The following conditions are treated as false:

  • The word "false"
  • The word "no"
  • An empty value
  • A list with no items, when using the #foreach helper
Make use of operators within the #if statement to further define when the statement should be outputted!

Operators

The following operators can be used in conjunction with an #if statement:

Operator

Use Case

Example

Output

=

To evaluate whether two values are equal to one another.

The second value can be a text string surrounded by double quotation marks or another data marker.

{{#if property.tenure = "Leasehold"}}You have indicated that the property is leasehold...{{#endif}}

If the data marker property.tenure is set to leasehold, the statement will be outputted.

If the data marker is set to any other value, the statement won't be outputted.

and

To evaluate the response of more than one data marker.

The response will be outputted if all conditions have been met.

{{#if funds.gifted and funds.saved}}As your source of funds includes both savings and a gift....{{#endif}}

If the data markers funds.gifted and funds.saved are set to true, the statement will be outputted.

If the data markers are set to false, the statement won't be outputted.

or

To evaluate the response of more than one data marker.

The response will be outputted if just one of the conditions have been met.

{{#if funds.gifted or funds.other}}Thank you for indicating...{{#endif}}

If the data marker funds.gifted or the data marker funds.other is set to true, the statement will be outputted.

If both data markers are set to false, the statement won't be outputted.

not

To evaluate whether a data marker's response is set to false.

{{#if not funds.gifted}}You have indicated that you are not receiving any gifted funds...{{#endif}}

If the data marker funds.gifted is set to false, the statement will be outputted.

If the data marker is set to true, the statement won't be outputted.

!=

To evaluate whether two values are not equal to one another.

The second value can be a text string surrounded by double quotation marks or another data marker.

{{#if property.tenure != "Leasehold"}}You have indicated that the property is not leasehold...{{#endif}}

If the data marker property.tenure is set to leasehold, the statement will not be outputted.

If the data marker is set to any other value, the statement will be outputted.

contains

To evaluate whether multiple choice type data contains a specific set of answers.

{{#if risk.assessment.risks contains "Flood"}}

There is a risk of flooding at this property, and we recommend that you consult Barry Smith & Co to understand the full risk potential.

{{#endif}}

{{#if risk.assessment.risks contains "Contaminated Land"}}

There is a risk of....

{{#endif}}

If the data marker risk.assessment contains "Flood" as an answer, the first statement will be outputted.

If the data marker contains "Contaminated Land" as an answer, the second statement will be outputted.

If the data marker contains both "Flood" and "Contaminated Land" as an answer, both statements will be outputted.

If the data marker contains neither, the statements will be ignored.

>

To evaluate whether one value is greater than another.

These values can be set as numbers or data markers.

{{#if property.price > 1,000,000}}You have indicated that the property value is more than £1 million...{{#endif}}

If the data marker property.price is more than 1,000,000, the statement will be outputted.

If the data marker is less than 1,000,000, the statement won't be outputted.

>=

To evaluate whether one value is greater than or equal to another.

These values can be set as numbers or data markers.

{{#if property.price >= 1,000,000}}You have indicated that the property value is more than or equal to £1 million...{{#endif}}

If the data marker property.price is more than or equal to 1,000,000, the statement will be outputted.

If the data marker is less than 1,000,000, the statement won't be outputted.

<

To evaluate whether one value is less than another.

These values can be set as numbers or data markers.

{{#if property.price < 1,000,000}}You have indicated that the property value is less than £1 million...{{#endif}}

If the data marker property.price is less than 1,000,000, the statement will be outputted.

If the data marker is more than 1,000,000, the statement won't be outputted.

<=

To evaluate whether one value is less than or equal to another.

These values can be set as numbers or data markers.

{{#if property.price <= 1,000,000}}You have indicated that the property value is less than or equal to £1 million...{{#endif}}

If the data marker property.price is less than or equal to 1,000,000, the statement will be outputted.

If the data marker is more than 1,000,000, the statement won't be outputted.

Use brackets to determine the order in which the expression is evaluated.
Evaluation order

Operators are evaluated in the following order:

  1. (...) brackets
  2. not
  3. > >= < <= contains
  4. = !=
  5. and
  6. or
#elseif

Can be used to add extra variables into the statement.

Example

Output

{{#if property.tenure = "Leasehold"}}

As this is a leasehold property...

{{#elseif property.tenure = "freehold"}}

You're buying a freehold property!

{{#endif}}

If the data marker property.tenure has "leasehold" saved against it, the first statement will be outputted.

If the data marker has "freehold" saved against it, the second statement will be outputted.

If the data is anything other than "leasehold" or "freehold" the statements will be ignored.

#else

Can be used to define an output if no other conditions have been met.

Example

Output

{{#if property.tenure = "Leasehold"}}

As this is a leasehold property...

{{#elseif property.tenure = "freehold"}}

You're buying a freehold property!

{{#else}}

We don't have any information on the tenure of the property.

{{#endif}}

If the data marker property.tenure has "leasehold" saved against it, the first statement will be outputted.

If the data marker has "freehold" saved against it, the second statement will be outputted.

If the data is anything other than "leasehold" or "freehold" the third statement will be outputted.

<< Previous      Next >>
Powered by HelpDocs (opens in a new tab)