Class: Deplate::Regions::DefElement
- Inherits:
-
Define
- Object
- Element
- Deplate::Region
- Define
- Deplate::Regions::DefElement
- Defined in:
- lib/deplate/define.rb
Constant Summary collapse
- @@def_element_counter =
0
Instance Method Summary collapse
Methods inherited from Define
check_arguments, #finish, let_variables, #valid_id?, #valid_switch
Methods inherited from Deplate::Region
check_file, clean_strings, #deprecated_regnote, deprecated_regnote, #finish, #finish_accum, #format_compound, regions, register_as, set_line_cont, #setup
Methods inherited from Element
#join_lines, #join_lines_re_zh_cn
Instance Method Details
#define ⇒ Object
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/deplate/define.rb', line 200 def define rx = deprecated_regnote('rx') if rx @@def_element_counter += 1 # template = @accum.join("\n").gsub(/\'/, "\\\\\'") template = @accum.join("\n") # rx = Regexp.new(rx).source.gsub(/\//, '\\\\/') rx = %r{^#{rx}} multiline = valid_switch(@args['multiline'], 'true') collapse = valid_switch(@args['collapse'], 'false') body = <<-EOR set_rx(#{rx.inspect}) class_attribute :tpl, #{template.inspect} def setup @multiliner = #{multiline} @collapse = #{collapse} @accum = [@match[0]] end EOR @args[:register] = true @args[:super] = Deplate::Define::Element cls = Deplate::Cache.element(@deplate, body, @args) end end |