{% macro render_provider_table(prefix, identifier, providers) -%}
    {% if providers %}
        <table class="table table-hover table-striped">
            <thead class="table-">
            <tr>
                <th scope="col">Name</th>
                <th scope="col">Metaprefix</th>
                <th scope="col">URI</th>
            </tr>
            </thead>
            <tbody>
            {% for provider in providers %}
                <tr>
                    <td>
                        {% if provider.homepage %}
                            <a href="{{ provider.homepage }}">{{ provider.name }}</a>
                        {% else %}
                            {{ provider.name }}
                        {% endif %}
                    </td>
                    <td class="text-nowrap"><code>{{ provider.metaprefix }}</code></td>
                    <td>
                        <a href="{{ provider.uri }}">{{ provider.uri }}</a>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    {% endif %}
{% endmacro %}

{% macro render_author(author, link=none) -%}
    {% if link or author.email %}
        <a href="{% if link %}{{ link }}{% else %}mailto:{{ author.email }}{% endif %}">
            {% if author.name %}
                {{ author.name }}
            {% else %}
                {{ author.email }}
            {% endif %}
        </a>
    {% else %}
        {% if author.name %}
            {{ author.name }}
        {% endif %}
    {% endif %}
    {% if author.orcid %}
        &nbsp;
        <small>
            <i class="fab fa-orcid"></i>
            <a href="https://orcid.org/{{ author.orcid }}">
                {{ author.orcid }}
            </a>
        </small>
    {% endif %}
    {% if author.github %}
        &nbsp;
        <small>
            <i class="fab fa-github"></i>
            <a href="https://github.com/{{ author.github }}">
                {{ author.github }}
            </a>
        </small>
    {% endif %}
{% endmacro %}

{% macro render_author_modal(prefix, author, key) %}
    <div class="modal fade" id="{{ key }}-modal" tabindex="-1" role="dialog" aria-labelledby="{{ key }}ModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="{{ key }}ModalLabel">Programmatic Access to {{ key|title }} Information</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    {% if author.name %}
                        <p>
                            Get the contact's name:
                        </p>
                        <pre><code class="language-python">&gt;&gt;&gt; import bioregistry as br
&gt;&gt;&gt; br.get_contact_name("{{ prefix }}")
'{{ author.name }}'</code></pre>
                    {% endif %}
                    {% if author.email %}
                        <p>
                            Get the contact's email:
                        </p>
                        <pre><code class="language-python">&gt;&gt;&gt; import bioregistry as br
&gt;&gt;&gt; br.get_contact_email("{{ prefix }}")
'{{ author.email }}'</code></pre>
                    {% endif %}
                    {% if author.github %}
                        <p>
                            Get the contact's GitHub handle:
                        </p>
                        <pre><code class="language-python">&gt;&gt;&gt; import bioregistry as br
&gt;&gt;&gt; br.get_contact_github("{{ prefix }}")
'{{ author.github }}''</code></pre>
                    {% endif %}
                    {% if author.orcid %}
                        <p>
                            Get the contact's ORCiD identifier:
                        </p>
                        <pre><code class="language-python">&gt;&gt;&gt; import bioregistry as br
&gt;&gt;&gt; br.get_contact_orcid("{{ prefix }}")
'{{ author.orcid }}'</code></pre>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
{% endmacro %}

{% macro code_example(prefix, func, text, quote=True) -%}
<pre><code class="language-python">&gt;&gt;&gt; import bioregistry as br
&gt;&gt;&gt; br.{{ func }}("{{ prefix }}")
{% if quote %}'{{ text }}'{% else %}{{ text }}{% endif %}</code></pre>
{% endmacro %}
