Class: Haml::MagicTranslations::XGetText::HamlParser::XGetTextParser

Inherits:
Object
  • Object
show all
Defined in:
lib/haml/magic_translations/xgettext/haml_parser.rb

Overview

:nodoc:all

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ XGetTextParser

Returns a new instance of XGetTextParser.



29
30
31
32
33
34
35
36
37
# File 'lib/haml/magic_translations/xgettext/haml_parser.rb', line 29

def initialize(file)
  if file.respond_to? :read
    @file = '(haml)'
    @content = file.read
  else
    @file = file
    @content = File.open(file).read
  end
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



28
29
30
# File 'lib/haml/magic_translations/xgettext/haml_parser.rb', line 28

def content
  @content
end

#fileObject (readonly)

Returns the value of attribute file.



27
28
29
# File 'lib/haml/magic_translations/xgettext/haml_parser.rb', line 27

def file
  @file
end

Instance Method Details

#parseObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/haml/magic_translations/xgettext/haml_parser.rb', line 39

def parse
  # Engine#initialize parses and compiles
  HamlEngineCompiler.filename = @file
  Haml::Engine.new(
      content, :filename => @file,
               :parser_class => HamlEngineParser,
               :compiler_class => HamlEngineCompiler)
  targets = HamlEngineCompiler.targets
  HamlEngineCompiler.reset_targets
  targets
end