Module: Haml::I18n::Extractor::Helpers::StringHelpers

Included in:
TextFinder
Defined in:
lib/haml-i18n-extractor/helpers.rb

Instance Method Summary collapse

Instance Method Details

#could_match_script?(txt) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/haml-i18n-extractor/helpers.rb', line 14

def could_match_script?(txt)
  # want to match:
  # = 'foo'
  # = "foo"
  # = link_to 'bla'
  #
  # but not match:
  # = ruby_var = 2
  scanner = StringScanner.new(txt)
  scanner.scan(/\s+/)
  scanner.scan(/['"]/) || scanner.scan(/link_to/)
end

#html_comment?(txt) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/haml-i18n-extractor/helpers.rb', line 7

def html_comment?(txt)
  txt.match(/<!--/) || txt.match(/-->\s*$/)
end

Returns:

  • (Boolean)


10
11
12
# File 'lib/haml-i18n-extractor/helpers.rb', line 10

def link_to?(txt)
  txt.match(/link_to/) || txt.match(/^\s*['"]/) # %element= 'foo'
end