Sha256: 09a940b5304e76d7f6cec85997536885c56bfd67d0061603cbc09f561653feea

Contents?: true

Size: 534 Bytes

Versions: 5

Compression:

Stored size: 534 Bytes

Contents

module Skellington
  class Template
    attr_reader :name
    attr_accessor :params, :outpath

    def initialize name
      @name = name
      @outpath = name
    end

    def templates_dir
      File.join File.dirname(__FILE__), '..', 'templates'
    end

    def write
      FileUtils.mkdir_p File.dirname @outpath
      f = File.open @outpath, 'w'
      f.write self
      f.close
    end

    def to_s
      t = File.read(File.open("#{templates_dir}/#{@name}.eruby"))
      Erubis::Eruby.new(t).result(@params)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
skellington-0.0.7 lib/skellington/template.rb
skellington-0.0.6 lib/skellington/template.rb
skellington-0.0.5 lib/skellington/template.rb
skellington-0.0.4 lib/skellington/template.rb
skellington-0.0.2 lib/skellington/template.rb