Sha256: a5f43bf41d5482cf9d27d9a5e8c80b4e0f79e9b42a0c4bd90d42f39ff1226781

Contents?: true

Size: 470 Bytes

Versions: 3

Compression:

Stored size: 470 Bytes

Contents

module Wovnrb
  class LinkReplacer < ReplacerBase
    def initialize(pattern, headers)
      @pattern = pattern
      @headers = headers
    end

    def replace(dom, lang)
      dom.xpath('//a').each do |node|
        next if wovn_ignore?(node)

        href = node.get_attribute('href')
        next if href =~ /^\s*\{\{.+\}\}\s*$/
        new_href = lang.add_lang_code(href, @pattern, @headers)
        node.set_attribute('href', new_href)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wovnrb-0.2.13 lib/wovnrb/html_replacers/link_replacer.rb
wovnrb-0.2.12 lib/wovnrb/html_replacers/link_replacer.rb
wovnrb-0.2.11 lib/wovnrb/html_replacers/link_replacer.rb