Module: GetText::HamlParser
Instance Method Summary collapse
-
#init(config) ⇒ Object
Sets some preferences to parse Haml files.
-
#parse(file) ⇒ Object
:nodoc:.
-
#target?(file) ⇒ Boolean
:nodoc:.
Instance Method Details
#init(config) ⇒ Object
Sets some preferences to parse Haml files.
- config: a Hash of the config. It can takes some values below:
- :extnames: An Array of target files extension. Default is [".haml"].
33 34 35 36 37 |
# File 'lib/gettext/tools/parser/haml.rb', line 33 def init(config) config.each do |key, value| @config[key] = value end end |
#parse(file) ⇒ Object
:nodoc:
39 40 41 42 43 44 45 |
# File 'lib/gettext/tools/parser/haml.rb', line 39 def parse(file) # :nodoc: precompiled = Haml::Engine.new(IO.read(file)).precompiled lines = precompiled.lines.to_a lines = lines[0..3] lines = ['"#{_("XXX")}"'] RubyParser.parse_lines(file, lines) end |
#target?(file) ⇒ Boolean
:nodoc:
47 48 49 50 51 52 |
# File 'lib/gettext/tools/parser/haml.rb', line 47 def target?(file) # :nodoc: @config[:extnames].each do |extname| return true if File.extname(file) == extname end false end |