Skip to content

Instantly share code, notes, and snippets.

@jeremyboggs
Last active November 28, 2015 21:49
Show Gist options
  • Save jeremyboggs/c6e5e8da007074a7fdb1 to your computer and use it in GitHub Desktop.
Save jeremyboggs/c6e5e8da007074a7fdb1 to your computer and use it in GitHub Desktop.
Parse a list of authors with Liquid templating. Handles single and multiple authors.
{% assign authors = page.author %}
{% if authors %}
<p>By
{% for author in authors %}
{% if forloop.last and forloop.length > 1 %} and {% endif %}<span resource="{{ author.resource }}" typeof="Person" property="creator"><em property="rdfs:label">{{ author.name }}</em></span>{% if forloop.last == false and forloop.length > 2 %}, {% endif %}{% endfor %}.</p>
{% endif %}
</p>
---
author:
- name: First Last
resource: http://example.com/page/First_Last
- name: First Last
resource: http://example.com/page/First_Last
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment