Class: Tilt::EtanniTemplate

Inherits:
Template show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/etanni.rb

Instance Attribute Summary

Attributes inherited from Template

#data, #file, #line, #options

Instance Method Summary collapse

Methods inherited from Template

#basename, default_mime_type, default_mime_type=, #eval_file, #initialize, metadata, #metadata, #name, #render

Constructor Details

This class inherits a constructor from Tilt::Template

Instance Method Details

#precompiled(locals) ⇒ Object



22
23
24
25
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/etanni.rb', line 22

def precompiled(locals)
  source, offset = super
  [source, offset + 1]
end

#precompiled_template(locals) ⇒ Object



18
19
20
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/etanni.rb', line 18

def precompiled_template(locals)
  @code
end

#prepareObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/etanni.rb', line 5

def prepare
  separator = data.hash.abs
  chomp = "<<#{separator}.chomp!"
  start = "\n_out_ << #{chomp}\n"
  stop = "\n#{separator}\n"
  replacement = "#{stop}\\1#{start}"

  temp = data.strip
  temp.gsub!(/<\?r\s+(.*?)\s+\?>/m, replacement)

  @code = "_out_ = [<<#{separator}.chomp!]\n#{temp}#{stop}_out_.join"
end