-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failures when front matter contains dates #14
Comments
Solved! I had to new up a Loader and pass it into parse_file like this: class PostsController < ApplicationController
def index
files = Dir.glob(File.join(Rails.root, "posts", "*.md"))
@posts = files.map do |f|
parsed = FrontMatterParser::Parser.parse_file(
f,
loader: FrontMatterParser::Loader::Yaml.new(allowlist_classes: [Date])
)
Post.new(f, parsed.front_matter)
end
end |
That's it 🙂 |
@waiting-for-dev Would it make sense to update this gem to include It is very common to have a date in the front matter. It would be nice if it was accepted without raising exceptions. |
Thanks for your feedback, @collimarco. I think it makes sense to have it as a default. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I try to parse a doc that looks like this:
It fails with:
Full trace:
This is my PostsController:
My goal is to iterate over my blog posts, authored in markdown with front matter that contains title and date and render a simple list. My bet is we need to pass some permitted classes to the yaml loader?
This conversation seems relevant: ruby/psych#262
The text was updated successfully, but these errors were encountered: