Class: Haml::Engine

Inherits:
Object
  • Object
show all
Defined in:
lib/gettext/haml.rb,
lib/gettext/haml_parser.rb

Overview

Haml gettext module providing gettext translation for all Haml plain text calls pastie.org/445295

Instance Method Summary collapse

Instance Method Details

#close_filtered(filter) ⇒ Object



40
41
42
43
# File 'lib/gettext/haml_parser.rb', line 40

def close_filtered(filter)
  @gettext_filters.pop
  super
end

#parse_tag(line) ⇒ Object

Overriden function that parses Haml tags Injects gettext call for plain text action.



17
18
19
20
21
22
23
# File 'lib/gettext/haml_parser.rb', line 17

def parse_tag(line)
  tag_name, attributes, attributes_hashes, object_ref, nuke_outer_whitespace,
    nuke_inner_whitespace, action, value, last_line = super(line)
  @precompiled << "_('#{value.escape_single_quotes}')\n" unless action && action != '!' || action == '!' && value[0..0] == '=' || value.empty?
  [tag_name, attributes, attributes_hashes, object_ref, nuke_outer_whitespace,
      nuke_inner_whitespace, action, value, last_line]
end

#push_flat(line) ⇒ Object



29
30
31
32
33
34
# File 'lib/gettext/haml_parser.rb', line 29

def push_flat(line)
  return super(line) if @gettext_filters.nil? || !@gettext_filters.last
  text = line.unstripped
  return if text == ''
  @precompiled << "_('#{text.escape_single_quotes}')\n"
end

#push_plain(text) ⇒ Object

Inject _ gettext into plain text and tag plain text calls



26
27
28
# File 'lib/gettext/haml_parser.rb', line 26

def push_plain(text)
  @precompiled << "_('#{text.escape_single_quotes}')\n"
end

#start_filtered(name) ⇒ Object



35
36
37
38
39
# File 'lib/gettext/haml_parser.rb', line 35

def start_filtered(name)
  @gettext_filters ||= []
  @gettext_filters.push( (name == 'markdown') )
  super
end