Class: Liquid::Ifchanged

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

Constant Summary

Constants inherited from Block

Block::ContentOfVariable, Block::FullToken, Block::TAGSTART, Block::VARSTART

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, #create_variable, #parse, #render_token_with_profiling, #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::Tag

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