Return nil from capture id result isn't a String

Rail's capture helper returns nil if nothing is written to the buffer
and the result of the block isn't a String.

Change Haml's helper to match this behaviour.

Fixes #439
(cherry picked from commit 754ac46ec73cb8a6cbeee0f5ceba77439237ebd9)