Module: GetText::ErbParser

Defined in:
lib/gettext/parser/erb.rb

Class Method Summary collapse

Class Method Details

.init(config) ⇒ Object

Sets some preferences to parse ERB files.

  • config: a Hash of the config. It can takes some values below:

    • :extnames: An Array of target files extension. Default is [“.rhtml”].



25
26
27
28
29
# File 'lib/gettext/parser/erb.rb', line 25

def init(config)
  config.each{|k, v|
	@config[k] = v
  }
end

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

:nodoc:



31
32
33
34
# File 'lib/gettext/parser/erb.rb', line 31

def parse(file, targets = []) # :nodoc:
  erb = ERB.new(IO.readlines(file).join).src.split(/$/)
  RubyParser.parse_lines(file, erb, targets)
end

.target?(file) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


36
37
38
39
40
41
# File 'lib/gettext/parser/erb.rb', line 36

def target?(file) # :nodoc:
  @config[:extnames].each do |v|
	return true if File.extname(file) == v
  end
  false
end