Module: RubyLLM::Registry::FrontMatter
- Defined in:
- lib/ruby_llm/registry/front_matter.rb
Overview
Simple YAML front matter parser for prompt files.
Class Method Summary collapse
Class Method Details
.parse(content) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ruby_llm/registry/front_matter.rb', line 12 def parse(content) return [{}, content] unless content.start_with?("---\n") parts = content.split("\n---\n", 2) return [{}, content] if parts.length != 2 header = parts.first.sub(/\A---\n/, "") body = parts.last = YAML.safe_load(header, permitted_classes: [Date, Time, Symbol], aliases: true) || {} = .each_with_object({}) { |(key, value), hash| hash[key.to_sym] = value } [, body] rescue Psych::SyntaxError [{}, content] end |