class Middleman::Renderers::Liquid
Liquid
Renderer
Public Instance Methods
after_configuration()
click to toggle source
After config, setup liquid partial paths
# File lib/middleman-core/renderers/liquid.rb, line 9 def after_configuration ::Liquid::Template.file_system = self end
manipulate_resource_list(resources)
click to toggle source
# File lib/middleman-core/renderers/liquid.rb, line 22 def manipulate_resource_list(resources) return resources unless app.extensions[:data] resources.each do |resource| next if resource.file_descriptor.nil? next unless resource.file_descriptor[:full_path].to_s =~ %r{\.liquid$} # Convert data object into a hash for liquid resource.add_metadata locals: { data: stringify_recursive(app.extensions[:data].data_store.to_h) } end end
map_value(thing)
click to toggle source
# File lib/middleman-core/renderers/liquid.rb, line 42 def map_value(thing) case thing when Hash stringify_recursive(thing) when Array thing.map { |v| map_value(v) } else thing end end
read_template_file(template_path, _)
click to toggle source
Called by Liquid
to retrieve a template file
# File lib/middleman-core/renderers/liquid.rb, line 14 def read_template_file(template_path, _) file = app.files.find(:source, "_#{template_path}.liquid") raise ::Liquid::FileSystemError, "No such template '#{template_path}'" unless file file.read end
stringify_recursive(hash)
click to toggle source
# File lib/middleman-core/renderers/liquid.rb, line 36 def stringify_recursive(hash) {}.tap do |h| hash.each { |key, value| h[key.to_s] = map_value(value) } end end