Module: GettextI18nRails::HamlParser
- Defined in:
- lib/gettext_i18n_rails/haml_parser.rb
Instance Method Summary (collapse)
Instance Method Details
- (Object) load_haml
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/gettext_i18n_rails/haml_parser.rb', line 27 def load_haml return true if @haml_loaded begin require "#{::Rails.root.to_s}/vendor/plugins/haml/lib/haml" rescue LoadError begin require 'haml' # From gem rescue LoadError puts "A haml file was found, but haml library could not be found, so nothing will be parsed..." return false end end @haml_loaded = true end |
- (Object) parse(file, msgids = [])
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gettext_i18n_rails/haml_parser.rb', line 16 def parse(file, msgids = []) return msgids unless load_haml require 'gettext_i18n_rails/ruby_gettext_extractor' text = IO.readlines(file).join haml = Haml::Engine.new(text) code = haml.precompiled return RubyGettextExtractor.parse_string(code, file, msgids) end |
- (Boolean) target?(file)
12 13 14 |
# File 'lib/gettext_i18n_rails/haml_parser.rb', line 12 def target?(file) File.extname(file) == '.haml' end |