Sha256: b3fc96a9e28c61aaa176843eb59688e703284c65b8e951285693b2b52cfea446

Contents?: true

Size: 706 Bytes

Versions: 2

Compression:

Stored size: 706 Bytes

Contents

module Tadpole
  module SectionProviders
    class TemplateProvider < SectionProvider
      EXTENSIONS = ['']
      
      def self.path_suitable?(full_path) File.directory?(full_path) end
      
      def initialize(full_path, owner)
        self.owner = owner
        Tadpole.template_paths.each do |template_path|
          if full_path.index(template_path) == 0
            path = full_path[template_path.length..-1]
            @template = Tadpole(owner.path, path).new(owner.options)
          end
        end
        raise ArgumentError, "no template at `#{full_path}'" unless @template
      end
      
      def render(locals = {}, &block)
        @template.run(locals)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tadpole-0.1.1 lib/tadpole/providers/template.rb
tadpole-0.1.0 lib/tadpole/providers/template.rb