Sha256: efe8561ae33488efe1293be85bb430e49e947e1213f29e50eb8a3f9dacb249bc

Contents?: true

Size: 565 Bytes

Versions: 15

Compression:

Stored size: 565 Bytes

Contents

module Bonsai
  class Template    
    class NotFound < StandardError; end
    
    # Class methods
    class << self
      attr_accessor :path

      def path
        @path || "templates"
      end
      
      def find(name)
        disk_path = Dir["#{path}/#{name}.*"]
        
        if disk_path.any? 
          new disk_path.first
        else
          raise NotFound, "template '#{name}' not found at #{path}"
        end
      end
    end
    
    # Instance methods
    attr_reader :path
    
    def initialize(path)
      @path = path
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
bonsai-1.4.9 lib/bonsai/template.rb
bonsai-1.4.8 lib/bonsai/template.rb
bonsai-1.4.7 lib/bonsai/template.rb
bonsai-1.4.6 lib/bonsai/template.rb
bonsai-1.4.5 lib/bonsai/template.rb
bonsai-1.4.4 lib/bonsai/template.rb
bonsai-1.4.3 lib/bonsai/template.rb
bonsai-1.4.2 lib/bonsai/template.rb
bonsai-1.4.1 lib/bonsai/template.rb
bonsai-1.3.2 lib/bonsai/template.rb
bonsai-1.3.1 lib/bonsai/template.rb
bonsai-1.3.0 lib/bonsai/template.rb
bonsai-1.2.0 lib/bonsai/template.rb
bonsai-1.1.6 lib/bonsai/template.rb
bonsai-1.1.5 lib/bonsai/template.rb