Class: BootstrapEmail::Converter::SupportUrlTokens

Inherits:
Base
  • Object
show all
Defined in:
lib/bootstrap-email/converters/support_url_tokens.rb

Constant Summary collapse

OPEN_BRACKETS =
CGI.escape('{{').freeze
CLOSE_BRACKETS =
CGI.escape('}}').freeze

Instance Attribute Summary

Attributes inherited from Base

#doc

Class Method Summary collapse

Methods inherited from Base

build, #initialize

Constructor Details

This class inherits a constructor from BootstrapEmail::Converter::Base

Class Method Details

.replace(html) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/bootstrap-email/converters/support_url_tokens.rb', line 9

def self.replace(html)
  regex = /((href|src)=("|').*?)((#{Regexp.quote(OPEN_BRACKETS)}).*?(#{Regexp.quote(CLOSE_BRACKETS)}))(.*?("|'))/
  return unless regex.match?(html)

  html.gsub!(regex) do |_match|
    "#{Regexp.last_match(1)}#{CGI.unescape(Regexp.last_match(4))}#{Regexp.last_match(7)}"
  end
end