Reputation: 972
I'm using Jekyll, which uses the Liquid Template language. I've used Jinja templating in the past, and it has the concept of a macro (just a named function). Does Liquid have something which provides equivalent functionality? If not, is there some Jekyll plugin which will extend Liquid to provide it?
Upvotes: 7
Views: 2605
Reputation: 3959
You can create includes that accept parameters. It's not quite a macro but it's what I've used successfully on GitHub Pages.
More details and tips for managing includes and using parameters can be found in the Jekyll documentation.
Here's an example:
_includes/email_link.html
<a href="mailto:{{ include.user.email_address }}"
title="Email {{ include.user.name }}">
<i class="fa fa-fw fa-envelope"></i>
</a>
about.md
---
layout: page
title: About
---
{% include email_link.html user=site.users.erik %}
_config.yml
users:
erik:
name: Erik
email_address: [email protected]
Upvotes: 12