Module: GettextI18nRails::HamletParser

Defined in:
lib/gettext_i18n_rails/hamlet_parser.rb

Class Method Summary collapse

Class Method Details

.parse(file, msgids = []) ⇒ Object



16
17
18
19
20
21
# File 'lib/gettext_i18n_rails/hamlet_parser.rb', line 16

def parse(file, msgids = [])
  return msgids unless prepare_hamlet_parsing
  text = File.read(file)
  code = Hamlet::Engine.new.call(text)
  RubyGettextExtractor.parse_string(code, file, msgids)
end

.prepare_hamlet_parsingObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/gettext_i18n_rails/hamlet_parser.rb', line 23

def prepare_hamlet_parsing
  return true if @hamlet_loaded
  begin
    require 'hamlet'
  rescue LoadError
    puts "A hamlet file was found, but hamlet library could not be found, so nothing will be parsed..."
    return false
  end
  require 'gettext_i18n_rails/ruby_gettext_extractor'
  @hamlet_loaded = true
end

.target?(file) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/gettext_i18n_rails/hamlet_parser.rb', line 12

def target?(file)
  File.extname(file) == '.hamlet'
end