alphagov/smartdown — pull request #12 by heathd (2014-08-01 15:08:33+00:00)
Title: Conditional

Adds support for conditional blocks in outcomes.

The syntax is:

```markdown
$IF pred?

Text if true

more text if you like

$ENDIF
```

You can also have an else clause:

```markdown
$IF pred?

Text if true

$ELSE

Text if false

$ENDIF
```

It's required to have a blank line between each if statement and the next paragraph of text, in other words this would be **invalid**:

```markdown
$IF pred?
Text if true
$ENDIF
```

If you call `Engine#process` you will get a state object back. If you then want to evaluate the node in that state to resolve conditionals you must call `Engine#evaluate_node(state)` which will evaluate the `current_node` as defined by the `state`. I had considered making `Engine#process` return a tuple of `(state, evaluated_node)`, but not sure if you would want to always evaluate the node. Thoughts welcome.