class Frozen::Template::Base
Attributes
file_path[RW]
template_root_path[RW]
Public Instance Methods
build_extension()
click to toggle source
# File lib/frozen/template/base.rb, line 58 def build_extension ".html" end
build_file_path()
click to toggle source
# File lib/frozen/template/base.rb, line 41 def build_file_path File.join(build_path,relative_path,build_filename) .sub(/^[\/\.]+/,'') end
build_filename()
click to toggle source
# File lib/frozen/template/base.rb, line 33 def build_filename filename = File.basename(file_path, ".#{file_type}") unless File.extname(filename) == build_extension filename << build_extension end filename end
build_path()
click to toggle source
# File lib/frozen/template/base.rb, line 53 def build_path "" end
file_type()
click to toggle source
# File lib/frozen/template/base.rb, line 63 def file_type File.extname(file_path)[1..-1] end
read_from_file(file)
click to toggle source
# File lib/frozen/template/base.rb, line 9 def read_from_file(file) @file_path = file File.read(file) end
relative_path()
click to toggle source
# File lib/frozen/template/base.rb, line 15 def relative_path return "" unless template_root_path pn_template_root_path = Pathname.new(template_root_path) pn_file_path = Pathname.new(file_path) val = pn_file_path.relative_path_from(pn_template_root_path) .dirname.to_s val = "" if val == "." val end
relative_to_root()
click to toggle source
# File lib/frozen/template/base.rb, line 46 def relative_to_root Pathname.new(".") .relative_path_from(Pathname.new(relative_path)) .to_s .sub(/^\/\./,'') end
render_to_file(file)
click to toggle source
# File lib/frozen/template/base.rb, line 26 def render_to_file(file) unless Dir.exist?(File.dirname(file)) FileUtils.mkdir_p(File.dirname(file)) end File.write(file, render) end
template_filename()
click to toggle source
# File lib/frozen/template/base.rb, line 67 def template_filename File.basename(file_path) end
template_path()
click to toggle source
# File lib/frozen/template/base.rb, line 71 def template_path File.dirname(file_path) end