Module: Jekyll::ConrefifierUtils
- Defined in:
- lib/jekyll-conrefifier.rb
Class Attribute Summary collapse
-
.og_paths ⇒ Object
Returns the value of attribute og_paths.
Class Method Summary collapse
- .convert(content, data_vars) ⇒ Object
-
.data_file_variables(config, path) ⇒ Object
fetch the custom scope vars, as defined in _config.yml.
- .setup_config(site, opts, path) ⇒ Object
Class Attribute Details
.og_paths ⇒ Object
Returns the value of attribute og_paths.
3 4 5 |
# File 'lib/jekyll-conrefifier.rb', line 3 def og_paths @og_paths end |
Class Method Details
.convert(content, data_vars) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/jekyll-conrefifier.rb', line 21 def self.convert(content, data_vars) value = Liquid::Template.parse(content).render(data_vars) # protects against situations where [page.version] prevented a conversion if value =~ /\{\{/ value = Liquid::Template.parse(value).render(data_vars) end value = value.gsub('"', '\"') end |
.data_file_variables(config, path) ⇒ Object
fetch the custom scope vars, as defined in _config.yml
6 7 8 9 10 11 12 13 |
# File 'lib/jekyll-conrefifier.rb', line 6 def self.data_file_variables(config, path) data_vars = {} scopes = config['data_file_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 |
.setup_config(site, opts, path) ⇒ Object
15 16 17 18 19 |
# File 'lib/jekyll-conrefifier.rb', line 15 def self.setup_config(site, opts, path) data_vars = path.nil? ? {} : ConrefifierUtils.data_file_variables(site.config, opts[:actual_path] || path) config = { 'page' => data_vars } config = { 'site' => { 'data' => site.data, 'config' => site.config } }.merge(config) end |