User Tools

Site Tools


harlowe:else

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

harlowe:else [2017/10/09 20:39] (current)
Line 1: Line 1:
 +**(else: ////) -> //​[[harlowe:​Changer|changer]]//​**
  
 +This is a convenient limited variant of the [[harlowe:​else-if|(else-if:​)]] macro. It will simply show
 +the attached hook if the preceding hook was hidden, and hide it otherwise.
 +If there was no preceding hook before this, then an error message will be printed.
 +
 +=== Rationale: ===
 +
 +After you've written a series of hooks guarded by [[harlowe:​if|(if:​)]] and [[harlowe:​else-if|(else-if:​)]],​ you'll often have one final
 +branch to show, when none of the above have been shown. (else:) is the "none of the above" variant
 +of [[harlowe:​else-if|(else-if:​)]],​ which needs no [[harlowe:​boolean|boolean]] expression to be provided. It's essentially the same as
 +''​%%(else-if:​ true)%%'',​ but shorter and more readable.
 +
 +For more information,​ see the documentation of [[harlowe:​else-if|(else-if:​)]].
 +
 +=== Notes: ===
 +
 +Just like the [[harlowe:​if|(if:​)]] macro, (else:) only checks its condition once, when the passage or hook contaning
 +it is rendered.
 +
 +Due to a mysterious quirk, it's possible to use multiple (else:) macro calls in succession:
 +
 +<​code>​
 +$isUtterlyEvil[You suddenly grip their ankles and spread your warm smile into a searing smirk.]
 +(else:​โ€‹)[In silence, you gently, reverently rub their soles.]
 +(else:​โ€‹)[Before they can react, you unleash a typhoon of tickles!]
 +(else:​โ€‹)[They sigh contentedly,​ filling your pious heart with joy.]
 +</​code>​
 +This usage can result in a somewhat puzzling passage source structure, where each (else:) hook
 +alternates between visible and hidden depending on the first such hook. So, it is best avoided.
 +
 +If you attach (else:) to a named hook, and the (else:) hides the hook, you can reveal the hook later
 +in the passage by using the [[harlowe:​show|(show:​)]] macro to target the hook.
 +
 +=== See also: ===
 +
 +[[harlowe:​if|(if:​)]],​ [[harlowe:​unless|(unless:​)]],​ [[harlowe:​else-if|(else-if:​)]],​ [[harlowe:​hidden|(hidden:​)]]
harlowe/else.txt ยท Last modified: 2017/10/09 20:39 (external edit)