Shopify/liquid — pull request #104 by jrallison (2012-03-04 03:58:48+00:00)
Title: Strict mode: raise error when variables aren't set

At [customer.io](http://customer.io), we are sending emails on our client's behalf using liquid templates.

We very much want to ensure our client's are sending emails they intend. For instance, if the template looks like:

Hi {{ customer.name }},

...rest of message...

and the client hasn't defined the customer's name, the email would render:

Hi ,

...rest of message...

We don't want to send any emails where the template is using a variable that isn't defined for one of the client's users. With that in mind, I'd added a `strict` mode which raises a `Liquid::VariableNotFound` error when a template tries to use a variable that isn't defined.

The goal of this change was to be purely opt-in. If you don't specify `strict` mode, Liquid will continue to work in a graceful way.

You can enable `strict` mode in two ways:

Liquid::Template.parse(template).render(variables, strict: true)

Or if you're creating a liquid context directly:

context.strict!

I would love any feedback on this change, and whether or not anyone feel it belongs in the main fork.

Thanks,
John