Sha256: 9a37c80cce0f2b80ead26ed7ce95b7e001b5e0179b980b146506bf1e29d945bf

Contents?: true

Size: 795 Bytes

Versions: 1

Compression:

Stored size: 795 Bytes

Contents

module Flutterby
  module Filters
    def apply!(file)
      body = file.source

      # Apply all filters
      file.filters.each do |filter|
        meth = "process_#{filter}"

        if Filters.respond_to?(meth)
          body = Filters.send(meth, body, file)
        end
      end

      file.body = body
    end

    def process_erb(input, file)
      tilt("erb", input).render(file.view)
    end

    def process_slim(input, file)
      tilt("slim", input).render(file.view)
    end

    def process_md(input, file)
      file.ext = "html"
      Slodown::Formatter.new(input).complete.to_s
    end

    def process_scss(input, file)
      Sass::Engine.new(input, syntax: :scss).render
    end

    def tilt(format, body)
      Tilt[format].new { body }
    end

    extend self
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flutterby-0.0.9 lib/flutterby/filters.rb