better-html icon indicating copy to clipboard operation
better-html copied to clipboard

Incorrect documentation in README for `template_exclusion_filter`?

Open neanias opened this issue 1 year ago • 0 comments

In the README, the documentation has this:

  • template_exclusion_filter: This is called when determining whether to apply runtime checks on a .erb template. When this Proc returns false, no safety checks are applied and parsing is done using the default Rails erubi engine. For example, to exclude erb templates provided by libraries, use: Proc.new { |filename| !filename.start_with?(Rails.root.to_s) }. Defaults to nil (all html.erb templates are parsed).

Is this the case? I think it should be that if the Proc returns true, it will use the Rails parser. This is based on my understanding of how the following three lines would execute depending on the return value of the filter:

https://github.com/Shopify/better-html/blob/fffc29c9f9c5b9c5d25b64932685b5d672005c9e/lib/better_html/better_erb.rb#L50-L52

The example proc is a valid proc for checking whether the template should be parsed.

neanias avatar Jul 15 '24 11:07 neanias