5.8.1 Directive closures and whitespace handling

Directive tags can be closed explicitly with #, or implicitly with the end of the line if you're feeling lazy.

#block testBlock #
Text in the body of the
block directive
#end block testBlock #
is identical to:
#block testBlock
Text in the body of the
block directive
#end block testBlock

When a directive tag is closed explicitly, it can be followed with other text on the same line:

bah, bah, #if $sheep.color == 'black'# black#end if # sheep.

When a directive tag is closed implicitly with the end of the line, all trailing whitespace is gobbled, including the newline character:

"""
foo #set $x = 2 
bar
"""
outputs 
"""
foo bar
"""

while 
"""
foo #set $x = 2 #
bar
"""
outputs 
"""
foo 
bar
"""

When a directive tag is closed implicitly AND there is no other text on the line, the ENTIRE line is gobbled up including any preceeding whitespace:

"""
foo 
   #set $x = 2 
bar
"""
outputs 
"""
foo
bar
"""

while 
"""
foo 
 - #set $x = 2
bar
"""
outputs 
"""
foo 
 - bar
"""

The #slurp directive (section 7.7) also gobbles up whitespace.

Spaces outside directives are output exactly as written. In the black sheep example, there's a space before ``black'' and another before ``sheep''. So although it's legal to put multiple directives on one line, it can be hard to read.

#if $a# #echo $a + 1# #end if
      - There's a space between each directive, 
        or two extra spaces total.
#if $a##echo $a + 1##end if
      - No spaces, but you have to look closely
        to verify none of the ``##'' are comment markers.
#if $a##echo $a + 1##end if     ### A comment.
      - In ``###'', the first ``#'' ends the directive, 
        the other two begin the comment.  (This also shows
	how you can add extra whitespace in the directive
	tag without affecting the output.)
#if $a##echo $a + 1##end if     # ## A comment.
      - More readable, but now there's a space before the
        comment.