Sha256: a6824b5fbcc95a88334beb5734325404ec757949786f136312be482fe6434be7

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

require 'haml'

module ::Haml
  module Filters

    module PreFile
      include ::Haml::Filters::Base

      def render(file)
        file.strip!
        plain_text = ::StaticCms::Helpers.to_plain(File.read(file))
        "<pre>#{plain_text}</pre>"
      end
    end

    module SampFile
      include ::Haml::Filters::Base

      def render(file)
        file.strip!
        plain_text = ::StaticCms::Helpers.to_plain(File.read(file))
        "<pre class='samp'><samp>#{plain_text}</samp></pre>"
      end

    module RubyCode
      include ::Haml::Filters::Base

      def render(text)
        ::StaticCms::Helpers.to_code(text, :ruby)
      end
    end

    module FortranCode
      include ::Haml::Filters::Base

      def render(text)
        ::StaticCms::Helpers.to_code(text, :fortran)
      end
    end
    end

    module Code
      include ::Haml::Filters::Base

      def render(text, lang = :general)
        ::StaticCms::Helpers.to_code(text, lang)
      end
    end

    module CodeFile
      include ::Haml::Filters::Base

      def render(file)
        file.strip!
        lang = ::StaticCms::Helpers::EXT_TO_LANG[File.extname(file)]
        text = File.read(file)
        ::StaticCms::Helpers.to_code(text, lang)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
static_cms-1.1.1 lib/static_cms/patch/haml.rb
static_cms-0.1.1 lib/static_cms/patch/haml.rb
static_cms-0.1.0 lib/static_cms/patch/haml.rb