Sha256: 2e71ed054d7ed34691b2612d4fb93feab502a0940a4acc023bd58d6a6b0c4977

Contents?: true

Size: 551 Bytes

Versions: 2

Compression:

Stored size: 551 Bytes

Contents

# frozen_string_literal: true
require 'tilt'
# Load tilt/haml only when haml is available
begin
  require 'haml'
rescue LoadError
else
  require 'tilt/haml'
end
require_relative 'engine'

module Faml
  class Tilt < Tilt::Template
    def prepare
      filename = nil
      if file
        filename = File.expand_path(file)
      end
      @code = Engine.new(options.merge(filename: filename)).call(data)
    end

    def precompiled_template(_locals = {})
      @code
    end
  end

  ::Tilt.register(Tilt, 'haml')
  ::Tilt.register(Tilt, 'faml')
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
faml-0.8.1 lib/faml/tilt.rb
faml-0.8.0 lib/faml/tilt.rb