Sha256: 82906fd3673b44babb8cd68864e96fa4eda9a9cf52291bca41c867d423cc0826

Contents?: true

Size: 506 Bytes

Versions: 1

Compression:

Stored size: 506 Bytes

Contents

require 'liquid'

module Conrefifier
  def self.file_variables(variables, path)
    return {} if variables.nil?

    data_vars = {}
    scopes = variables.select { |v| v[:scope][:path].empty? || Regexp.new(v[:scope][:path]) =~ path }
    scopes.each do |scope|
      data_vars = data_vars.merge(scope[:values])
    end
    data_vars
  end

  def self.apply_liquid(content, data_vars)
    data_vars['page'] = data_vars[:page].stringify_keys
    ::Liquid::Template.parse(content).render(data_vars)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nanoc-conref-fs-0.4.2 lib/nanoc-conref-fs/conrefifier.rb