module Rake::Templates
Constants
- VERSION
Public Instance Methods
all()
click to toggle source
# File lib/rake/templates.rb, line 15 def all Dir["templates/**/*"].map do |file| path = Pathname.new(file) next if path.directory? next if path.to_s =~ /^_/ path end.compact end
clean()
click to toggle source
# File lib/rake/templates.rb, line 51 def clean public.rmtree if public.exist? public.mkpath unless public.exist? end
compile(file)
click to toggle source
# File lib/rake/templates.rb, line 24 def compile(file) public.mkpath unless public.exist? template = Tilt.new(file.to_s) context = Context.new rendered_content = template.render(context) path = result_path(template) path.open("w") do |f| f << rendered_content end end
compile_all()
click to toggle source
# File lib/rake/templates.rb, line 45 def compile_all all.each do |file| compile file end end
public()
click to toggle source
# File lib/rake/templates.rb, line 11 def public Pathname.new("public") end
result_path(template)
click to toggle source
# File lib/rake/templates.rb, line 36 def result_path(template) extra_endings = template.file.split(".")[2..-1].join(".") dirname = File.dirname(template.file).gsub(/^templates/, "public") basename = template.basename(".#{extra_endings}") dir = Pathname.new(dirname) dir.mkpath dir.join(basename) end