Chapter 12: Using Conditional Statements

You can use conditional statements (such as if-then or if-then-else) to only display certain text. The statement is evaluated, and if true, the text is displayed in your document. In M2Doc, the if is followed by an AQL statement which returns true or false. Conditional statements can be useful within for loops.

In medini analyze, you can use conditional statements for filtering, as shown in these examples.

Example

  • Use a conditional statement to find exact matches with equals (=).

    { m:if req.identifier = 'SR-004' } ... { m:endif }
  • Or use a conditional statement to match items that start with a specific prefix.

    { m:if req.identifier.startsWith('SR') } ... { m:endif }

Tip:  If you are using multiple nested if statements, it may be difficult to see which endif closes which if statement. Because M2Doc ignores everything in the brackets after the endif, you can simply include a comment to identify it.

{ m:endif req.identifier }

For more information about conditional statements, see the M2Doc site.