Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect documentation in README for template_exclusion_filter? #137

Open
neanias opened this issue Jul 15, 2024 · 0 comments
Open

Incorrect documentation in README for template_exclusion_filter? #137

neanias opened this issue Jul 15, 2024 · 0 comments

Comments

@neanias
Copy link

neanias commented Jul 15, 2024

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:

excluded_template = !!BetterHtml.config.template_exclusion_filter&.call(template.identifier)
klass = BetterHtml::BetterErb.content_types[exts] unless excluded_template
klass ||= self.class.erb_implementation

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant