有没有办法在ruby中编辑标记文件顶部的YAML Frontmatter,就像在Jekyll和Middleman中使用的那样?在降价文件中编辑YAML Frontmatter
喜欢的东西:
def update_yaml
#magic that changes A: 1 to A: 2 in Frontmatter block
end
然后我的降价文件,这将改变从
---
A: 1
---
# Title
Words. More words. This is the words part of the file.
到
---
A: 2
---
# Title
Words. More words. This is the words part of the file.
这似乎是唯一的选择是解析整个文件,然后重写整个文件只改变了所需的部分,但我希望有更好的东西。