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