liquid icon indicating copy to clipboard operation
liquid copied to clipboard

Remove mutable render state from Liquid::Template

Open dylanahsmith opened this issue 5 years ago • 0 comments

Problem

Liquid::Template instances naturally holds the state of the parsed liquid template, but also holds mutable state related to rendering. That mutable rendering state makes it hard to reason about the behaviour of the template if it is used more than once for rendering. We also have a more naturally place to hold that rendering state, which is in the Liquid::Context that is already used to store the rendering state, except that it was being given mutable references to collection objects stored in the template instance.

Solution

Remove the rendering state from Liquid::Template and instead encourage the use of Liquid::Context to access mutable state like render errors.

This pull request removes the following methods from Liquid::Template:

  • resource_limits
  • registers
  • assigns
  • instance_assigns
  • errors
  • @rethrow_errors

dylanahsmith avatar Jul 22 '20 19:07 dylanahsmith