trvsdnn / frank

Static Site Non-Framework
http://github.com/blahed/frank
MIT License
413 stars 30 forks source link

custom META delimiter or support 3-hyphen #56

Open edrex opened 13 years ago

edrex commented 13 years ago

It is pretty common to use triple hyphens or equals to delimit a YAML header. For example blogofile, Jekyll, ymlfront plugin for ikiwiki, lots of others. Triple hyphen is also the standard YAML document separator.

It would be nice if:

a. Frank supported this delimiter out of box. Are there known conflicts with supported template languages for this delimiter? b. The delimiter regex was customizable in setup.rb.

If a. then edrex doesn't care about b.

I can make a patch for a or b.

edrex commented 13 years ago

btw, i'm mostly interested in this because I have heaps of files formatted like:

---
some
...
yaml
---
markdown

that i'd like to be able to drop into Frank

trvsdnn commented 13 years ago

Wouldn't be opposed to a.) at all, and it shouldn't conflict with anything. The yaml gets pulled out before anything else sees it.

joesavage commented 12 years ago

This type of delimiter, as far as I understand, is also necessary to be able to use YAML.load_file, which allows reading of YAML front matter from files. Unless I'm missing something, this functionality is very important for reading YAML front matter from files -- I'm currently creating a project in which I need to read "title" YAML data from my "dynamic" files using Frank and am getting hung up on this issue.

trvsdnn commented 12 years ago

Where are you using the data that you are reading from the dynamic file? The idea of the yaml header was that all of the keys would be available in your layout and templates automatically.

That being said, the only reason I haven't already switch the delimiter is because i'm wanting to rewrite the entire project, just haven't found the time yet.

joesavage commented 12 years ago

I was looking to read the YAML from a helper method which gathers information about some of the files in a given folder to list the files along with some of their YAML data for an "index" page type functionality.

trvsdnn commented 12 years ago

Ah, yeah. I'd suggest reading the file, splitting at the delimiter and just parsing the YAML bit for now, or take a stab at forking and changing the delimiter yourself to see if it gets you what you want.

joesavage commented 12 years ago

Parsing the YAML by using split to get only the YAML part of the file and then using some makeshift RegEx seems to be a viable solution for now (problem: solved).

trvsdnn commented 12 years ago

Leaving this open because it is on the list for the next release.