How to use YAML front and back matter in Ruby? -


i have heard of term "front matter" , "back matter" refer yaml parsing @ beginning or end of non-yaml file. however, can't seem find examples/documentation of how implement this. maybe isn't standard yaml feature. how can make use of feature in ruby project?

fyi: reason want able require ruby files @ top, , assume rest yaml. don't think allowed in yaml file.

i came across nice example of similar trying do. isn't example of "front/back matter" might in future:

using __end__ keyword, can stop ruby parsing rest of file. rest of file stored in data variable, file object:

#!/usr/bin/env ruby %w(yaml pp).each { |dep| require dep }  obj = yaml::load(data)  pp obj  __end__ --- -   name: adam   age: 28   admin: true -   name: maggie   age: 28   admin: false 

source


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -