Class: Jekyll::UJPowertools::IfTruthyTag
- Inherits:
-
Liquid::Block
- Object
- Liquid::Block
- Jekyll::UJPowertools::IfTruthyTag
- Includes:
- VariableResolver
- Defined in:
- lib/tags/iftruthy.rb
Instance Method Summary collapse
-
#initialize(tag_name, markup, tokens) ⇒ IfTruthyTag
constructor
A new instance of IfTruthyTag.
- #render(context) ⇒ Object
Methods included from VariableResolver
#is_quoted?, #parse_arguments, #parse_options, #resolve_input, #resolve_variable
Constructor Details
#initialize(tag_name, markup, tokens) ⇒ IfTruthyTag
Returns a new instance of IfTruthyTag.
9 10 11 12 |
# File 'lib/tags/iftruthy.rb', line 9 def initialize(tag_name, markup, tokens) super @variable = markup.strip end |
Instance Method Details
#render(context) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tags/iftruthy.rb', line 14 def render(context) # Use the helper to resolve input (handles both literals and variables) # Don't use prefer_literal for iftruthy - we want to check variables value = resolve_input(context, @variable, false) # Check if the value is truthy (not nil, not false, not empty string, not 0) if value && value != false && value != "" && value != 0 super else "" end end |