Trim result to avoid whitespace at the beginning of the rendered html.
Hack for now, avoid the Exception case.  Need to revisit when the try block will be worked.
Added variable substitution.  Currently, only empty values are substituted in.