Class: PufferPages::Liquid::Tracker
- Inherits:
-
Object
- Object
- PufferPages::Liquid::Tracker
- Defined in:
- lib/puffer_pages/liquid/tracker.rb
Instance Method Summary collapse
- #cleanup(text) ⇒ Object
-
#initialize ⇒ Tracker
constructor
A new instance of Tracker.
- #register(content) ⇒ Object
Constructor Details
#initialize ⇒ Tracker
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(/<%/, "<%").gsub(/%>/, "%>")# 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 |