-
Notifications
You must be signed in to change notification settings - Fork 7
Conditional statements
Giorgio Garofalo edited this page Oct 11, 2024
·
2 revisions
The .if
function begins a conditional statement.
- Its first parameter is the condition (
Boolean
) to satisfy; - The second parameter is a parameter-less lambda, invoked only if the condition is satisfied.
.if {yes}
Hello, Quarkdown!
Hello, Quarkdown!
The function returns the evaluation of the lambda if the condition is satisfied; nothing otherwise.
This means the function propagates its content up the stack.
<!-- Read this from bottom to top -->
.if {yes} <!-- (nothing) -->
.if {no} <!-- (nothing) -->
.if {yes} <!-- Hello! -->
.if {yes} <!-- Hello! -->
Hello!
(no output)
This allows the function to be used as part of any expression:
.row
A
.if {condition}
B
C
The .ifnot
function is a shorthand that inverts .if
's behavior, returning a concrete value only if the condition is not satisfied.
The else statement is not yet implemented. It could however be emulated thanks to the .let
function:
.let {condition}
.if {.1} <!-- .1 is the implicit lambda argument, equal to let's value -->
Result if true
.ifnot {.1}
Result if false
- Syntax of a function call
- Declaring functions
- Dynamic typing
- Localization
- Including other Quarkdown files
- Importing external libraries
- Document metadata
- Theme
- Page format
- Page margin content
- Page counter
- Automatic page break
- Numbering
- Table of contents
- Stacks (row, column, grid)
- Align
- Container
- Box
- Collapsible
- Whitespace
- String
- Number
- Markdown content
- Boolean
- Enumeration entry
- Iterable
- Dictionary
- Range
- Lambda
- Size(s)
- Color
- Dynamic