Sha256: dc95fc3d003c46b36af404464e1168d9a53bfc003ebf80a27e6e0484af42bf7a
Contents?: true
Size: 1013 Bytes
Versions: 2
Compression:
Stored size: 1013 Bytes
Contents
# frozen_string_literal: true require 'liquid' require 'yaml' module Frise # Provides a static parse method for reading a config from a YAML file applying the required # transformations. module Parser class << self def parse(file, symbol_table = nil) return nil unless File.file? file YAML.safe_load(parse_as_text(file, symbol_table), aliases: true) || {} end def parse_as_text(file, symbol_table = nil) return nil unless File.file? file content = File.read(file) template = Liquid::Template.parse(content, error_mode: :strict) if symbol_table content = template.render!(with_internal_vars(file, symbol_table), { strict_filters: true }) end content end private def with_internal_vars(file, symbol_table) symbol_table.merge('_file_dir' => File.expand_path(File.dirname(file))) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
frise-0.6.1 | lib/frise/parser.rb |
frise-0.6.0 | lib/frise/parser.rb |