kolber / stacey

Cheap & easy content management
http://staceyapp.com
MIT License
1.04k stars 131 forks source link

sub variables? #148

Closed zachkrall closed 7 years ago

zachkrall commented 8 years ago

I am not sure if this might be possible, but I was curious if it's possible to define custom sub variables and run a loop to print whatever may be defined.

{{ metadata.* }} ??

Right now, for my projects on my website, I have a "metadata" section that includes things like the date, medium, dimensions, etc. it would be nice to be able to define a new piece of data without also having to update the template.

title: Project Title

metadata:
    year: 2016
    medium: Archival Inkjet Print
    dimensions: 20 x 15 inches

content:+++
Description
+++

Essentially, I'd like to avoid making a table with markdown so that the template remains flexible if the design changes in the future.

pbatts commented 8 years ago

You can try:

{% for data in page.metadata if data %}
{{ data }}
{% endfor %}
zachkrall commented 8 years ago

I'll try that! Thanks

zachkrall commented 8 years ago

realizing there are some helpful suggestions in this thread https://github.com/kolber/stacey/issues/97

pbatts commented 8 years ago

Lots of good stuff here too. https://github.com/kolber/Stacey-Snippets/wiki