•••
 
Documentation   /   General   /   Logic statements
 
 

Logic statements

 

[[IF]]

Syntax

[[IF=variable_name]]Some text[[ENDIF]]
[[IF=variable_name(My test)]]Some text[[ENDIF]]
[[IF=variable_name(MATCH_TYPE My test)]]Some text[[ENDIF]]
[[IF=variable_name(MATCH_TYPE My test)]]Some text
[[ELSEIF=variable_name(MATCH_TYPE My test)]]Some other text
[[ELSE]]Some more text
[[ENDIF]] 

Notes

  • You can include single conditions only. Ie. You can't use AND or OR.
  • You can't include a NOT statement inside an IF statement.


[[NOT]]

Syntax

[[NOT=variable_name]]Some text[[ENDNOT]]
[[NOT=variable_name(My test)]]Some text[[ENDNOT]]
[[NOT=variable_name(MATCH_TYPE My test)]]Some text[[ENDNOT]]

Notes

  • You can include single conditions only. Ie. You can't use AND or OR.
  • You can include IF statements inside a NOT statement.


[[VAR]]

Syntax

[[VAR=variable_name]]{variable_value}[[ENDVAR]]
[[VAR=variable_name,save:true|false]]{variable_value}[[ENDVAR]]

Notes

  • If save:true, the variable will be saved into the document. Useful for building queries afterwards via Data Studio.
  • Other statements (e.g. IF/ELSE) can be included inside [[VAR]] statements.


[[CHANGE]]

Syntax

[[CHANGE=function_1|function_2(argument_1,argument_2)]]{text}[[ENDCHANGE]] 
  • Commas and pipes are escaped with ::ok
  • E.G. ,::ok and |::ok

Available functions

CAPITALIZE
Converts the first character in {text} to uppercase
CAPITALIZE_ALL
Converts the first character of each word in {text} to uppercase
COUNT_CHARS
Returns the number of characters in {text}
COUNT_WORDS
Returns the number of words in {text}
FOR_URL
Replaces any spaces or punctuation in {text} with -
LOWERCASE
Converts {text} to lowercase
NO_LINES
Removes any line breaks from {text}
NUMBER_IN_WORDS
If {text} is a number, converts the number to text.
ONLY_ALPHA
Removes any non-alphabetical characters from {text}
ONLY_NUMBER
Removed any non-numerical characters from {text}
PART({start},{length})
Returns only part of {text}, starting after {start} characters and ending after {length}
PLAINTEXT
Removes all html tags from {text}
PLURALIZE({number},{plural})
Pluralizes {text} depending on {number}. If {plural} is not set, s is used.
REPLACE({find},{replace})
Replaces {find} with {replace} in {text}
SAFE_LINES
Replaces any line breaks in {text} with ~~~ so they can be parsed by Plainly
TRIM
Eliminates any whitespace at the beginning or end of {text}
TRUNCATE({num_characters})
Truncates {text} to {num_characters} followed by …
UPPERCASE
Converts {text} to uppercase


[[DATE]]

Syntax

[[DATE=format,calculation]]{starting_timestamp}[[ENDDATE]]
  • Commas and pipes are escaped with ::ok
  • E.G. ,::ok and |::ok

Options for format

  • ISO 8601
  • RFC 2822
  • UNIX
  • D|DD
  • MM|MMM|MMMM
  • YY|YYYY

Options for calculation

  • x seconds|minutes|hours|days|months|years ago
  • in x seconds|minutes|hours|days|months|years

N.B. months equates to calendar months


[[MATH]]

Format

[[MATH=option_1,option_2]]{text}[[ENDMATH]]

Options

  • decimals:{number}
  • round:{up|down|ceiling|floor}
  • currency:{currency}
  • date_format:{format}
  • percentage

Notes

  • If set, decimals will also round the number, unless rounding is also set.
  • {format} takes the same formats as used in [[DATE]].


[[INCLUDE]]

Syntax

[[INCLUDE={include_type}:{include_target}]]
[[INCLUDE={include_type}({options}):{include_target}]]

Types

document:{document_key}
Includes another Plainly document
document_data:{document_key}
Includes the data only from another Plainly document
template:{template_key}
Includes another of your templates
image:{image_URL}
Includes an image. No dimensions set.
image({w}x{h}):{image_URL}
Includes an image with width set to {w} and height set to {h}
image({w}):{image_URL}
Includes an image with width set to {w} only
image(x{h}):{image_URL}
Includes an image with height set to {h} only
data:{data_source}
Includes JSON data with source of {data_source}