Class: Liquid::Ifchanged

Inherits:
Block show all
Defined in:
lib/liquid/tags/ifchanged.rb

Instance Attribute Summary

Attributes inherited from Tag

#line_number, #nodelist, #options, #warnings

Instance Method Summary collapse

Methods inherited from Block

#blank?, #block_delimiter, #block_name, #initialize, #nodelist, #parse, #unknown_tag, #warnings

Methods inherited from Tag

#blank?, #initialize, #name, parse, #parse, #raw

Methods included from ParserSwitching

#parse_with_selected_parser

Constructor Details

This class inherits a constructor from Liquid::Block

Instance Method Details

#render(context) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/liquid/tags/ifchanged.rb', line 4

def render(context)
  context.stack do

    output = super

    if output != context.registers[:ifchanged]
      context.registers[:ifchanged] = output
      output
    else
      ''.freeze
    end
  end
end