Class: Liquid::Autoescape::Exemption
- Inherits:
-
Object
- Object
- Liquid::Autoescape::Exemption
- Defined in:
- lib/liquid/autoescape/exemption.rb
Overview
An exemption that may apply to a Liquid template variable
Exemptions are created from functions that accept a template variable and and return a boolean value indicating whether or not the variable is exempt from auto-escaping.
Instance Method Summary collapse
-
#applies?(variable) ⇒ Boolean
Determine whether the exemption applies to a Liquid variable.
-
#initialize(&filter) ⇒ Exemption
constructor
Create a new auto-escaping exemption.
Constructor Details
#initialize(&filter) ⇒ Exemption
Create a new auto-escaping exemption
This requires a filter function to be provided that will be passed a TemplateVariable
instance that it can use to return a boolean indicating whether the exemption applies to the variable.
31 32 33 34 |
# File 'lib/liquid/autoescape/exemption.rb', line 31 def initialize(&filter) raise ExemptionError, "You must provide an exemption with a block that determines if an exemption applies" unless block_given? @filter = filter end |
Instance Method Details
#applies?(variable) ⇒ Boolean
Determine whether the exemption applies to a Liquid variable
40 41 42 |
# File 'lib/liquid/autoescape/exemption.rb', line 40 def applies?(variable) @filter.call(variable) end |