Constants (Literals)
The following literal types are supported:
- Boolean:
true,false,True,False. - Integer: for example:
-1,0,1,2. - Float: for example:
1.2,1.0. - String: text wrapped in quotes (single quotes
', double quotes", or backticks`; must use ASCII half-width characters). Opening and closing quotes must match. If the string contains the same type of quote, use a different quote type for the outer wrapper. For example,"Welcome to 'Everkm' Notes". - List: wrapped with
[and], items separated by half-width commas. All items must be of the same type; a trailing comma is allowed. For example,["abc", "efg",].
Variables
Variables are typically defined in the template context, but can also be defined within a template.
Variable types include all the literal types listed above, plus object types. An object is a collection of one or more key-value pairs where keys must be strings, values can be any other type, different pairs may have different value types, and values can themselves be objects, forming nested structures.
Variables can be rendered using the {{var_name}} syntax.
System Global Variables
__publish_contextcontext of the current template__qsquery parameters of the current page (Query string), includingfolders.*.queryconfig items; page parameters override config items with the same name__configtheconfigconfiguration items__page_pathfile path corresponding to the current page__page_path_basesame as__page_path, but without the file extension__breadcrumbsbreadcrumb navigation. Data structure:[{"title":"", url: ""}]__langthe configured language code__tpl_pathcurrent template path__hosthost of the current preview address__env_is_previewwhether this is a preview environment (boolean)__everkm_publish_versioncurrent tool version__theme_versioncurrent theme version__theme_namecurrent theme name
Dot Operator
When accessing a list, you can use var.0 to access the first item, with numbering starting from 0.
When accessing an object, use var.key to get the value for the specified key.
Bracket Operator
When accessing a list, you can use var[0] to access the first item.
When accessing an object, use var["key"] to get the value for the specified key.
When accessing deeply nested objects, you can chain multiple bracket accesses. For example: cities["zhongguo"]["hubei"]["wuhan"]. The content after the operator is called the index; in addition to literals, valid variables can also be used as the index.
Accessing undefined variables through the above operators will cause an error.
Expressions
The following categories of expressions are supported:
Arithmetic Operators
Everkm Publish supports basic numeric operators. Operations are only allowed on numbers (integers, floats) and numeric variables.
+adds the left and right operands. For example,{{1+2}}outputs3.-subtracts the right operand from the left. For example,{{2-1}}outputs1.*multiplies the left and right operands. For example,{{1*2}}outputs2./divides the left operand by the right. For example,{{ 10 / 2 }}outputs5.%returns the remainder of the left operand divided by the right. For example,{{ 2 % 2 }}outputs0.
Operator precedence: from lowest to highest; same-precedence operators are evaluated left to right.
+,-*,/,%
Comparison Operators
==equal!=not equal>greater than>=greater than or equal<less than<=less than or equal
Logical Operators
andlogical AND; returns true when both sides are trueorlogical OR; returns true when either side is truenotlogical NOT; negates the operand
Concatenation Operator
Concatenates all operands. Operands include strings, numbers, and other identifiers (such as functions, macros, etc.).
{{ "hello " ~ 'world' ~ `!` }}
{{ an_ident ~ " and a string" ~ another_ident }}
{{ an_ident ~ another_ident }}
in Operator
Checks whether the left operand is contained in the right operand.
{{ some_var in [1, 2, 3] }}
{{ 'index' in page.path }}
{{ an_ident not in an_obj }}