Sha256: cea6b48934dcee8268eb77dc415f0d9eb532f1c3a6c055cd9b54ba9b6f693532

Contents?: true

Size: 644 Bytes

Versions: 4

Compression:

Stored size: 644 Bytes

Contents

require 'pathname'

module Sanford

  class TemplateEngine

    attr_reader :source_path, :opts

    def initialize(opts = nil)
      @opts = opts || {}
      @source_path = Pathname.new(@opts['source_path'].to_s)
    end

    def render(path, service_handler, locals)
      raise NotImplementedError
    end

  end

  class NullTemplateEngine < TemplateEngine

    def render(path, service_handler, locals)
      template_file = self.source_path.join(path).to_s
      unless File.exists?(template_file)
        raise ArgumentError, "template file `#{template_file}` does not exist"
      end
      File.read(template_file)
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sanford-0.11.1 lib/sanford/template_engine.rb
sanford-0.11.0 lib/sanford/template_engine.rb
sanford-0.10.1 lib/sanford/template_engine.rb
sanford-0.10.0 lib/sanford/template_engine.rb