Class: PufferPages::Liquid::Tracker

Inherits:
Object
  • Object
show all
Defined in:
lib/puffer_pages/liquid/tracker.rb

Instance Method Summary collapse

Constructor Details

#initializeTracker

Returns a new instance of Tracker.



5
6
7
# File 'lib/puffer_pages/liquid/tracker.rb', line 5

def initialize
  @ids = []
end

Instance Method Details

#cleanup(text) ⇒ Object



14
15
16
17
18
19
# File 'lib/puffer_pages/liquid/tracker.rb', line 14

def cleanup text
  ids = @ids.join('|')
  @ids = []
  text = text.gsub(/<%/, "&lt;%").gsub(/%>/, "%&gt;")# unless PufferPages.config[:allow_erb]
  text.gsub(/<(#{ids})%/, "<%").gsub(/%(#{ids})>/, "%>")
end

#register(content) ⇒ Object



9
10
11
12
# File 'lib/puffer_pages/liquid/tracker.rb', line 9

def register content
  @ids << Digest::MD5.hexdigest(SecureRandom.uuid)
  content.gsub(/<%/, "<#{@ids.last}%").gsub(/%>/, "%#{@ids.last}>")
end