Class: Bridgetown::LiquidRenderer::FileSystem
- Inherits:
-
Liquid::LocalFileSystem
- Object
- Liquid::LocalFileSystem
- Bridgetown::LiquidRenderer::FileSystem
- Defined in:
- lib/bridgetown-core/liquid_renderer/file_system.rb
Instance Attribute Summary collapse
-
#site ⇒ Object
Returns the value of attribute site.
Instance Method Summary collapse
Instance Attribute Details
#site ⇒ Object
Returns the value of attribute site.
6 7 8 |
# File 'lib/bridgetown-core/liquid_renderer/file_system.rb', line 6 def site @site end |
Instance Method Details
#read_template_file(template_path) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/bridgetown-core/liquid_renderer/file_system.rb', line 8 def read_template_file(template_path) load_paths = root found_paths = [] load_paths.each do |load_path| # Use Liquid's gut checks to verify template pathname self.root = load_path full_template_path = full_path(template_path) # Look for .liquid as well as .html extensions path_variants = [ Pathname.new(full_template_path), Pathname.new(full_template_path).sub_ext(".html"), ] found_paths << path_variants.find(&:exist?) end # Restore pristine state self.root = load_paths found_paths.compact! raise Liquid::FileSystemError, "No such template '#{template_path}'" if found_paths.empty? # Last path in the list wins ::File.read(found_paths.last, **site.file_read_opts) end |