It puzzled me ...
I would like to share a YAML hash from a single file among several other Jekyll pages.
I know that you can put it in the Front Matter (which will require duplicating it), and I know that you can create (write) pages through the plugin (but I use it on several different types of pages, which will be difficult). Not what I'm looking for.
I would like to iterate over the hash with Liquid on my pages, but I cannot get the hash from the Liquid plugin. {% capture %} only works with strings, and {% assign %} will not allow you to call a tag inside yourself, for example {% assign projects = gethash %} , where gethash is a regular Liquid tag.
Basically, I would like to use a separate YAML file as a text database.
The YAML file has the following:
projects: category1: - title: Project 1 desc: Description etc... - title: Project 2 etc... category2: - title: Project 3 desc: Description etc... - title: Project 4 etc...
The plugin is called (which gives the Ruby Hash YAML):
def... YAML::load(File.read('projects.yml')) end...
And in the template I want:
{% for p in projects %} ...
It should be very simple, but it is one of those fluid things that is pain.
How can you get the hash in Liquid from the plugin for use in the {% for %} loop?
source share