cobalt-org / liquid-rust

Liquid templating for Rust
docs.rs/liquid
MIT License
473 stars 79 forks source link

Add optional support for lax rendering and parsing #492

Open RyanAmos opened 1 year ago

RyanAmos commented 1 year ago

Following up on the issue I created here: https://github.com/cobalt-org/liquid-rust/issues/490

This PR introduces two functional changes. The first being supporting a "lax" parsing mode, the second being a "lax" rendering mode. Each additional change extends the functionality, but does not change the default behavior.

Parsing Mode:

In lax parsing mode, an undefined filter will simply return an internal noop filter. That filter will simply pass along the string to the next filter, if one is provided.

In strict parsing mode, an undefined filter will continue to return an error.

Rendering Mode:

In lax rendering mode, an undefined variable will simply be rendered as a nil value which will ultimately result in an empty string.

In strict rendering mode, an undefined variable will continue to return an error.