Module: GettextI18nRails::HamlParser
- Defined in:
- lib/gettext_i18n_rails/haml_parser.rb
Class Method Summary collapse
Class Method Details
.load_haml ⇒ Object
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 |
.parse(file, msgids = []) ⇒ Object
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 |
.target?(file) ⇒ Boolean
12 13 14 |
# File 'lib/gettext_i18n_rails/haml_parser.rb', line 12 def target?(file) File.extname(file) == '.haml' end |