1. Bigle Academy
  2. Templates - Create tags
  3. Types of use of opening and closing tags

Tags to condition texts to the value of a numeric field

The platform offers us the possibility of configuring a Number type field so that, depending on the value entered in the form, one sentence or another is displayed in the final document.

For this to happen, in the template, we must include the texts that we want to condition between the following opening and closing tags:

  • Greater than the value:
    {#numberRAW >2}Text A{/}
  • Equal to the value:
    {#numberRAW ===2}Text B{/}
  • Lower than the value:
    {#numberRAW <2}Text C{/}


On the one hand, the opening tags ({#numberRAW >2}, {#numberRAW ===2} and {#numberRAW <2}) are made up of:

  • The same tag as the Number field one (in this case, “number”):
Field tag
  • RAW >2”, “RAW ===2” and “RAW <2”, which determine the condition in which the text will appear:
    • RAW >2”: When the field value is greater than 2, “Text A” will be shown.
    • RAW ===2”: When the field value is equal to 2, “Text B” will be shown.
    • RAW <2”: When the field value is lower than 2, “Text C” will be shown.
  •  “2” is the value that conditions each of the texts in the previous example, but it may vary depending on the desired result.

 On the other hand, the closing tag is the same each time: {/}.


In the same template, we can use the three previous tag configurations, as well as two of them or only one, depending on the needs of each case. In addition, we can combine different tags in the same sentence.

Here are several examples using the Number field tag, the tags to condition text to the field value, and the number-to-word tag (learn more about it in this article):

 

{#numberRAW >2}Text A: {numberLETTERS} ({number}){/}  

  • If we enter a value greater than 2 (for example, 5) this sentence will appear:
    Text A: FIVE (5)

{#numberRAW ===2}Text B: {numberLETTERS} ({number}){/}  

  • If the entered value is 2, this sentence will appear:
    Text B: TWO (2)

{#numberRAW <2}Text C: {numberLETTERS} ({number}){/}  

  • If we enter a value lower than 2 (for example, 1) this sentence will appear:
    Text C: ONE (1)

Remember that, although in the previous examples we used the number 2, this configuration can be used with other values. In the same way, “Text A”, “Text B” and “Text C” must be replaced by the actual texts that we want to condition and “number” by the tag of the Number field.


To learn more about the Number type field and the options it offers, check out this article.

 

Use cases


Case 1:

It is possible to condition more than one piece of text in the same sentence. In the following example, in which the field refers to the number of years (“{years}”), we want the word “year” (in the singular) to appear if the entered value is 1, and the word "years" (in the plural) to be shown when entering a value greater than 1:

{yearsLETTERS} ({years}){#yearsRAW >1} years{/}{#yearsRAW ===1} year{/}  

  • If the value of the field is greater than 1 (for example, 5) this sentence will appear:
    FIVE (5) years
  • If the value of the field is 1, this other one will appear:
    ONE (1) year

Case 2:

Let's take a look to a slightly more complex example. Suppose that, depending on the duration of a contract, we want the amount of the Penalty Clause to vary. For example, we want the amount to be $1,000 if the duration is of 5 years or less, and $2,000, if the duration is of more than 5 years.

Use case

In this case, we will create two fields where enter the economic amount of each situation:

  • One of them could be titled "Amount of the penalty clause for a contract duration of 5 years or less" (with the tag "{penaltyclause1}").
  • The other one could be titled "Amount of the penalty clause for a contract duration of more than 5 years" (with the tag "{penaltyclause2}").

Taking into account that the appearance of one amount or another must depend on the number of years the contract lasts, we will create a numeric field (with the tag "{years}") and condition the other two fields to it:

The contract will last {yearsLETTERS} ({years}){#yearsRAW >1} years{/}{#yearsRAW ===1} year{/}. The amount of the Penalty Clause will be {#yearsRAW <5}{penaltyclause1}{/}{#yearsRAW ===5}{penaltyclause1}{/}{#yearsRAW >5}{penaltyclause2}{/}.


With this setup, after filling in the form fields with the respective amounts of $1,000 and $2,000; and entering a number of years:

  • If we enter "1" in the field {years}, this sentence will appear:
    The contract will last ONE (1) year. The amount of the Penalty Clause will be $1,000.
  • If we enter "5" in the field {years}, this sentence will appear:
    The contract will last FIVE (5) years. The amount of the Penalty Clause will be $1,000.
  • If we enter "8" in the field {years}, this sentence will appear:
    The contract will last EIGHT (8) years. The amount of the Penalty Clause will be $2,000.