Sha256: 24ff6ab839aa4c7508d4802b5e77bbac63b0a323a918ed0bfac8e893e417601f
Contents?: true
Size: 612 Bytes
Versions: 2
Compression:
Stored size: 612 Bytes
Contents
require 'liquid' module Conrefifier SINGLE_SUB = /(\{\{[^\}]+\}\})/m BLOCK_SUB = /\{% (?:if|unless).+? %\}.*?\{% end(?:if|unless) %\}/m 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nanoc-conref-fs-0.4.4 | lib/nanoc-conref-fs/conrefifier.rb |
nanoc-conref-fs-0.4.3 | lib/nanoc-conref-fs/conrefifier.rb |