Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional by citation count #310

Open
kaba2 opened this issue Jul 7, 2020 · 3 comments
Open

Conditional by citation count #310

kaba2 opened this issue Jul 7, 2020 · 3 comments

Comments

@kaba2
Copy link

kaba2 commented Jul 7, 2020

How can I use bibliography_count inside conditionals? The following Jekyll code fails by "Unknown operator bibliography_count":

{% if {% bibliography_count --cited %} > 0 %}

<h2>References</h2>

{%- bibliography --cited -%}
{% endif %}
@kaba2
Copy link
Author

kaba2 commented Jul 7, 2020

Here is a workaround. Is it supposed to work like this?

{%- capture citecount -%}
{%- bibliography_count --cited -%}
{%- endcapture -%}

{% if {{citecount}} != "0"  %}

<h2>References</h2>

{%- bibliography --cited -%}
{% endif %}

@AlasdairGray
Copy link

This was just what I was looking for. It would be great to add these instructions to the README.

@norseghost
Copy link

the above didn't work for me. this was my workaround:

{% comment %}
Capture cites so i can check for a populated list later
{% endcomment %}
{% capture cites %}
{% bibliography --cited_in_order %}
{% endcapture %}
{% comment %}
The bibliography tag returns an empty list if there are no citations
(nil would seem to make more sense, but hey)
Thus, check for a list element in the returned bibliography to indicate
I actually cited something in this article.
{% endcomment %}
{% if cites contains "<li" %} <section class="footnotes reference">
   <h1 id="">References</h1>
   {{cites | markdownify }}
   </section>
   {% endif %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants