Sha256: ce30643f4dbfb1586ab6c2f2958fa60ba51d8d92569e822e21a9db3504217eab
Contents?: true
Size: 1.29 KB
Versions: 13
Compression:
Stored size: 1.29 KB
Contents
module Locomotive module Steam module Liquid # A Liquid file system is a way to let your templates retrieve other templates for use with the include and sections tags. # # Example: # # Liquid::Template.file_system = Liquid::LocalFileSystem.new(template_path) # liquid = Liquid::Template.parse(template) # # This will parse the template from both the DB or the Filesystem. # class FileSystem attr_reader :section_finder, :snippet_finder def initialize(section_finder: nil, snippet_finder: nil) @section_finder, @snippet_finder = section_finder, snippet_finder end # Called by Liquid to retrieve a template file def read_template_file(template_path) type, name = template_path.split('--') entity = ( case type when 'sections' section_finder.find(name) when 'snippets' snippet_finder.find(name) else raise ::Liquid::FileSystemError, "This liquid context does not allow #{type}." end ) raise ::Liquid::FileSystemError, "Unable to find #{name} in the #{type} folder" if entity.nil? entity.liquid_source end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems