I'm running a Jekyll site that uses JSON as data in my _data
folder. I'm looping through the file like normal doing things like {% for item in site.data.resources.items %}
just fine. However, I'd like to parse YAML front matter that is within a string.
Example:
\n---\nblog: http://google.com\nbackground-img: http://www.ew.com/sites/default/files/i/2013/07/23/Dumb-and-Dumber.jpg\nbuttonText: Download\n---\n
How can I have Liquid parse this within my Jekyll site so I can use it like so:
<a href="{{blog}}"><img src="{{background-img}}>Image</a>
or something similar?
EDIT: To clarify, that string is in front matter format in a text file that I'm retrieving through an ajax call. So that string is the response I get back and the format won't be changing. My hope was that Liquid could somehow parse this string and look for a front matter type format. If not, I will revert back my JavaScript methods.
background-img
andbuttonText
child key-value pairs of theblog
item in that structure? If so, perhaps something like front matter entryitem: blog
and in content<a href="{{ site.data.resources.items.[page.item] }}"><img src="{{site.data.resources.items.[page.item].background-img}}>Image</a>
. Is that what you mean? – TBB