File: haml_parser.rb

package info (click to toggle)
ruby-gettext-i18n-rails 1.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 148 kB
  • sloc: ruby: 515; makefile: 6
file content (28 lines) | stat: -rw-r--r-- 600 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'gettext_i18n_rails/base_parser'

module GettextI18nRails
  class HamlParser < BaseParser
    def self.extension
      "haml"
    end

    def self.convert_to_code(text)
      case @library_loaded
      when "haml"
        if Haml::VERSION.split('.').first.to_i <= 5
          Haml::Engine.new(text).precompiled()
        else
          Haml::Engine.new.call(text)
        end
      when "hamlit"
        Hamlit::Engine.new.call(text)
      end
    end

    def self.libraries
      ["haml", "hamlit"]
    end
  end
end

GettextI18nRails::GettextHooks.add_parser GettextI18nRails::HamlParser