Class: Amrita2::Filters::Default

Inherits:
Base show all
Defined in:
lib/amrita2/template.rb

Instance Attribute Summary

Attributes inherited from Base

#next_

Instance Method Summary collapse

Methods inherited from Base

filter_method, inherited, #parse_filter_a, #|

Constructor Details

#initialize(default_value_src) ⇒ Default

Returns a new instance of Default.



2116
2117
2118
# File 'lib/amrita2/template.rb', line 2116

def initialize(default_value_src)
  @default_value_src = default_value_src
end

Instance Method Details

#value_filter_code(de, cg, value) ⇒ Object



2120
2121
2122
2123
2124
2125
2126
2127
# File 'lib/amrita2/template.rb', line 2120

def value_filter_code(de, cg, value)
  cg.if_("$_") do
    super
    cg.else_ do
      cg.code("$_ = (#{@default_value_src.inspect})")
    end
  end
end

#value_filter_code_old(de, cg, value) ⇒ Object



2129
2130
2131
2132
# File 'lib/amrita2/template.rb', line 2129

def value_filter_code_old(de, cg, value)
  cg.code("$_ = $_ || (#{@default_value_src.inspect})")
  super
end