module Frise::Parser
Provides a static parse method for reading a config from a YAML file applying the required transformations.
Public Class Methods
parse(file, symbol_table = nil)
click to toggle source
# File lib/frise/parser.rb, line 11 def parse(file, symbol_table = nil) return nil unless File.file? file YAML.safe_load(parse_as_text(file, symbol_table), [], [], true) || {} end
parse_as_text(file, symbol_table = nil)
click to toggle source
# File lib/frise/parser.rb, line 16 def parse_as_text(file, symbol_table = nil) return nil unless File.file? file content = File.read(file) content = Liquid::Template.parse(content).render with_internal_vars(file, symbol_table) if symbol_table content end
Private Class Methods
with_internal_vars(file, symbol_table)
click to toggle source
# File lib/frise/parser.rb, line 25 def with_internal_vars(file, symbol_table) symbol_table.merge('_file_dir' => File.expand_path(File.dirname(file))) end