class ExtractI18n::HTMLExtractor::Match::PlainTextMatch

Public Class Methods

create(document, node) click to toggle source
# File lib/extract_i18n/html_extractor/match/plain_text_match.rb, line 5
def self.create(document, node)
  return nil if node.name.start_with?('script')
  node.text.split(/\@\@(=?)[a-z0-9\-]+\@\@/).map! do |text|
    new(document, node, text.strip) if !text.nil? && !text.empty?
  end
end

Public Instance Methods

replace_text!(key, i18n_t) click to toggle source
# File lib/extract_i18n/html_extractor/match/plain_text_match.rb, line 12
def replace_text!(key, i18n_t)
  document.erb_directives[key] = i18n_t
  node.content = node.content.gsub(text, "@@=#{key}@@")
end