module LiquidComponent
Constants
- FRONT_MATTER_REGEXP
- VERSION
Public Class Methods
has_yaml_header?(template)
click to toggle source
# File lib/liquid-component.rb, line 34 def self.has_yaml_header?(template) template.lines.first&.match? %r!\A---\s*\r?\n! end
parse(template)
click to toggle source
# File lib/liquid-component.rb, line 13 def self.parse(template) template = template.to_s yaml_data = {} file_content = nil if has_yaml_header?(template) if template = template.match(FRONT_MATTER_REGEXP) file_content = template.post_match yaml_data = SafeYAML.load(template.captures[0]) end else file_content = template end Component.new( metadata: Metadata.new(yaml_data), content: file_content ) end