Skip to content

Instantly share code, notes, and snippets.

@carlcs
Last active December 24, 2015 00:22
Show Gist options
  • Save carlcs/2320a8ca24449137f09d to your computer and use it in GitHub Desktop.
Save carlcs/2320a8ca24449137f09d to your computer and use it in GitHub Desktop.

Footnotes plugin - new syntax

Redactor Settings

Add "footnotes" to the "plugins" setting.

"plugins": ["footnotes"],

You can optionally edit the button label, configure an icon or define the button's position in the toolbar with the "footnoteButton" setting.

"footnoteButton": {
  "title": "Note",
  "icon": "footnote",
  "addAfter": "italic",
},

Templating Examples

A Single Article

{% do parseFootnoteDefinitions(footnotes) %}
{{ text|parseFootnoteMarkers }}
{{ getFootnotesHtml() }}

Multiple Articles

{% for entry in entries %}
    {% do parseFootnoteDefinitions(footnotes, entry.slug) %}
    {{ text|parseFootnoteMarkers(entry.slug) }}
    {{ getFootnotesHtml(entry.slug) }}
{% endfor %}

Custom Templates

{% do parseFootnoteDefinitions(footnotes) %}
{{ text|parseFootnoteMarkers(null, '_includes/footnotes/marker') }}
{{ getFootnotesHtml(null, '_includes/footnotes/list') }}

Usage with a Martix field

{% for block in blocks if block.type == 'footnotes' %}
    {% do parseFootnoteDefinitions(block.footnotes) %}
{% endfor %}

{% for block in blocks if block.type != 'footnotes' %}
    {% if block.type == 'text' %}
        {{ block.text|parseFootnoteMarkers }}
    {% endif %}
{% endfor %}

{{ getFootnotesHtml() }}

Usage with an array of note definitions (e.g. from a Super Table)

{% do setFootnoteDefinitions({
    '4': 'Bla bla',
    'g': 'More bla bla',
}) %}
{{ text|parseFootnoteMarkers }}
{{ getFootnotesHtml() }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment