Skip to content
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

Support YAML front matter #2

Open
weierophinney opened this issue Sep 2, 2015 · 1 comment
Open

Support YAML front matter #2

weierophinney opened this issue Sep 2, 2015 · 1 comment

Comments

@weierophinney
Copy link
Contributor

The github specification now allows/defines YAML front matter for mustache documents; this provides a way to create default values for the view.

In all cases, front matter begins and ends with a line containing only ---. You can have a single front matter section, or multiple front matter sections.

A single front matter section:


names: [ {name: chris}, {name: mark}, {name: scott} ]

{{#names}}
Hi {{name}}!
{{/names}}
Multiple front matter sections:


name: chris

name: mark

name: scott

Hi {{name}}!
Technically, this is a feature of the mustache command, and not necessarily required by implementations. However, when considering things like template inheritance, it could be a useful feature.

@weierophinney
Copy link
Contributor Author

This package looks promising for parsing the frontmatter: https://github.com/mnapoli/FrontYAML

I'm not sure if this should be part of Mustache itself, or part of a facade class. It touches base on several aspects:

  • Lexing. It would need to execute prior to lexing, keeping the parsed YAML front matter as a view to associate with the given template, and passing the remainder of the document on to the lexer.
  • Rendering. It would need to pass the parsed YAML front matter on as a view against which to merge a user-supplied view when doing substitutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant