Shopify/liquid — pull request #131 by dasch (2012-06-12 08:44:28+00:00)
Title: Allow custom formatting of rendered nodes

This allows injecting a custom formatter that can transform the list of
rendered nodes into a string. The default formatter still simply joins
the parts.

By doing this, we allow people to do postprocessing on the result of a
Liquid evaluation, which can be useful for, say, HTML formatting.

```ruby
Template.formatter = lambda do |parts|
parts.map do |part|
if needs_html_escaping?(part)
escape_html(part)
else
part
end
end.join
end

template = Liquid::Template.parse("hello!\n\n{{foo}}\n\nbar")
template.render
```

The formatter is currently set globally on Template. It didn't seem like it was straightforward to inject in into the template per instance, although that may be preferable. If you'd rather want it per instance I can fix the code.