Text manipulation

# Formatting

Applies formatting to parts of the text.

Operation Format Description
Bold **text** or __text__ Formats the text as boldaface.
Italic *text* or _text_ Formats the text as italic type.
Strike ~~text~~ Formats the text as strike-through style.
Line break \n Creates a line break in the text (carriage-return).
Link [text](url) Creates a link with the label text to url.

The URL can be a website (http:\\ or https:\\), phone (tel:) or email (mailto:). The link will open in another tab or window.

Examples

{"type": "p", "value": "This **text is in bold** and this *text is in italics*."}
{"type": "p", "value": "Is this ~~the best~~ a good offer?\\n __yes__"}
{"type": "p", "value": "Check our [website](https://devgutt.github.io/evaluatly)"}

Example with variable substitution:

{"type": "p", "value": "The color is **{{color}}**"}

The substitution is applied before any formatting.

Example in check item option label:

{ "type": "check", 
    "options": [
        { "save_key": "accept-terms", "label": "I have **read** and **accept** the [terms](https://devgutt.github.io/evaluatly/terms)" } 
    ] 
}

# Variable substitution

To replace the value of a variable directly in the text, place the variable's name inside the substitution marker {{ }}.

For example, for a variable named color, you can use the value of the variable in the text using {{color}}.

{"type": "p", "value": "The color is {{color}}"}

By default the property value of the variable is used. To get the other properties, like label or id, use "." followed by the property name:

{"type": "p", "value": "The color's label is {{color.label}} and the id is {{color.id}}"}

# Variable modifiers

To make changes to the text, use the vertical bar | after the variable, with the desired function.

{"type": "p", "value": "The color is {{color|upper}}"}

The upper function will modify the value of the variable color to uppercase.

Modifiers can be chained and will be applied in sequence.

{"type": "p", "value": "My first name is {{name|first|upper}}"}

The list of modifiers is below:

Modifier Description
upper Transforms the variable to uppercase
lower Transforms the variable to lowercase
sub Returns part of the text
equal Returns text if equal
notEqual Returns text if not equal
less Returns text if the value is less
lessEqual Returns text if the value is less or equal
greater Returns text if the value is greater
greaterEqual Returns text if the value is greater or equal
default Returns the default value if the variable is empty.
first Returns the first word of a variable.
last Returns the last word of a variable.
word Returns the word of a variable by position

# upper

Transforms the variable to uppercase.

Examples

{ "type": "p", "value": "The color is {{color|upper}}" }

# lower

Transforms the variable to lowercase.

Examples

{ "type": "p", "value": "The color is {{color|lower}}" }

# sub (start, end)

Returns the part of the text between the start and end indexes, or to the end of the text.

Parameters

start

Start index (starting with 0)

end

End index. If not informed, the end of the text.

Examples

{ "type": "p", "value": "The color is {{color|sub(2,5)}}" }

Example end of the text:

{ "type": "p", "value": "The color is {{color|sub(2)}}" }

# equal (match, txtTrue, txtFalse)

Returns txtTrue if variable is equal to match, or txtFalse otherwise.

Examples

{ "type": "p", "value": "The color is red? {{color|equal('red', 'Yes', 'No')}}" }

# notEqual (match, txtTrue, txtFalse)

Returns txtTrue if variable is not equal to match, or txtFalse otherwise.

Examples

{ "type": "p", "value": "The color is not red? {{color|notEqual('red', 'Yes', 'No')}}" }

# less (var, txtTrue, txtFalse)

Returns txtTrue if variable is less than var, or txtFalse otherwise.

Examples

{ "type": "p", "value": "The result is {{result|less(20, 'Low', 'High')}}" }

# lessEqual (var, txtTrue, txtFalse)

Returns txtTrue if variable is less or equal to var, or txtFalse otherwise.

Examples

{ "type": "p", "value": "The result is {{result|lessEqual(20, 'Low', 'High')}}" }

# greater (var, txtTrue, txtFalse)

Returns txtTrue if variable is greater than var, or txtFalse otherwise.

Examples

{ "type": "p", "value": "The result is {{result|greater(20, 'High', 'Low')}}" }

# greaterEqual (var, txtTrue, txtFalse)

Returns txtTrue if variable is greater or equal to var, or txtFalse otherwise.

Examples

{ "type": "p", "value": "The result is {{result|greaterEqual(20, 'High', 'Low')}}" }

# default (txt)

Returns txt if the variable is empty.

Examples

{ "type": "p", "value": "The color is {{color|default('white')}}" }

# first

Returns the first word of a variable.

Examples

{ "type": "p", "value": "The first name is {{name|first}}" }

# last

Returns the last word of a variable.

Examples

{ "type": "p", "value": "The last name is {{name|last}}" }

# word (nth)

Returns nth word of a variable.

Examples

{ "type": "p", "value": "The name is {{name|word(1)}}" }