Class: Haml::MagicTranslations::Compiler
- Inherits:
-
Compiler
- Object
- Compiler
- Haml::MagicTranslations::Compiler
- Defined in:
- lib/haml/magic_translations.rb
Class Attribute Summary collapse
-
.magic_translations_helpers ⇒ Object
Returns the value of attribute magic_translations_helpers.
Instance Method Summary collapse
Class Attribute Details
.magic_translations_helpers ⇒ Object
Returns the value of attribute magic_translations_helpers.
78 79 80 |
# File 'lib/haml/magic_translations.rb', line 78 def magic_translations_helpers @magic_translations_helpers end |
Instance Method Details
#compile_filter ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/haml/magic_translations.rb', line 81 def compile_filter case @node.value[:name] when 'markdown', 'maruku' @node.value[:text] = "\#{_(<<-'END_OF_TRANSLATABLE_MARKDOWN'.rstrip #{@node.value[:text].rstrip.gsub(/\n/, '\n')} END_OF_TRANSLATABLE_MARKDOWN )}" when 'javascript' @node.value[:text].gsub!(/_\(('(([^']|\\')+)'|"(([^"]|\\")+)")\)/) do |m| to_parse = $1[1..-2].gsub(/"/, '\"') parsed_string = JSON.parse("[\"#{to_parse}\"]")[0] parsed_string.gsub!(/'/, "\\\\'") "\#{_('#{parsed_string}').to_json}" end end super end |
#compile_root ⇒ Object
99 100 101 102 |
# File 'lib/haml/magic_translations.rb', line 99 def compile_root @precompiled << "extend #{Compiler.magic_translations_helpers};" super end |