Class: Zwite::Liquid::FileSystem
- Defined in:
- lib/zwite/liquid/filesystem.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
Returns the value of attribute root.
Instance Method Summary collapse
- #full_path(template_path) ⇒ Object
-
#initialize(root) ⇒ FileSystem
constructor
A new instance of FileSystem.
- #read_template_file(template_path) ⇒ Object
Constructor Details
#initialize(root) ⇒ FileSystem
Returns a new instance of FileSystem.
9 10 11 |
# File 'lib/zwite/liquid/filesystem.rb', line 9 def initialize(root) @root = root end |
Instance Attribute Details
Instance Method Details
#full_path(template_path) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/zwite/liquid/filesystem.rb', line 19 def full_path(template_path) full_path = if template_path.include?('/') File.join(root, File.dirname(template_path), "#{File.basename(template_path)}") else File.join(root, "#{template_path}") end raise Exception::exception("Illegal template path '#{File.(full_path)}'") unless File.(full_path) =~ /^#{File.(root)}/ full_path end |
#read_template_file(template_path) ⇒ Object
13 14 15 16 17 |
# File 'lib/zwite/liquid/filesystem.rb', line 13 def read_template_file(template_path) full_path = full_path(template_path) raise Exception::exception("No such template '#{template_path}'") unless File.exists?(full_path) File.read(full_path) end |