Shopify/liquid — pull request #226 by fw42 (2013-07-12 19:57:39+00:00)
Title: Opt-in whitespace stripping during rendering

This moves #218 and some new stuff behind a config setting (stored in a context register). By default, no stripping will happen, neither during parsing nor during rendering.

The config setting is implemented as a context register. This way, it can be read everywhere (or even changed -- it would be easy to implement a "dont strip"-block-tag now, if necessary).

On top of the stripping during parsing (introduced in #218), this PR also strips tokens in the bodies of block tags which render to whitespace (like ```{% if false %} ... {% endif %}```, which wasn't stripped in #218, also see #162).

Also, for the output of block tags, we now strip lines which contain only newlines.

Content of raw tags is never stripped. I used the trick described [here](https://github.com/Shopify/liquid/issues/162#issuecomment-20809918) for that (thanks @nickpearson).

There is one problem this could cause: <pre> and <code> tags do not necessarily preserve whitespace anymore. I don't want to parse HTML to do this. I will add some logging to Shopify to see if anyone actually does this. If absolutely necessary, pre/code HTML tags can be combined with Liquid raw tags to achieve this.

Review: Some subset of {@csfrancis, @arthurnn, @dylanahsmith, @boourns, @hornairs} please.