Class: Liquid::Variable
- Inherits:
-
Object
- Object
- Liquid::Variable
- Defined in:
- lib/liquid/autoescape/liquid_ext/variable.rb
Instance Method Summary collapse
- #non_escaping_render ⇒ Object
-
#render(context) ⇒ String
Possibly render the variable with HTML escaping applied.
Instance Method Details
#non_escaping_render ⇒ Object
9 |
# File 'lib/liquid/autoescape/liquid_ext/variable.rb', line 9 alias non_escaping_render render |
#render(context) ⇒ String
Possibly render the variable with HTML escaping applied
If the auto-escaping context variable has been set by the autoescape % tag or Liquid auto-escaping is globally enabled, this will run the variable through the global exemption list to determine if it is exempt from auto-escaping. If it is not, its contents will be rendered as a string with all unsafe HTML characters escaped. In all other cases, the original, unescaped value of the variable will be rendered.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/liquid/autoescape/liquid_ext/variable.rb', line 22 def render(context) is_global = Autoescape.configuration.global? is_local = context[Autoescape::ENABLED_FLAG] if !is_global && !is_local return non_escaping_render(context) end if is_global && is_local == false is_exempt = true else variable = Autoescape::TemplateVariable.from_liquid_variable(self) is_exempt = Autoescape.configuration.exemptions.apply?(variable) end @filters << [:escape, []] unless is_exempt output = non_escaping_render(context) @filters.pop unless is_exempt output end |