Problem
I am using Bootstrap and Font Awesome in my project. I created a popover with content as the data variable. By clicking on button(that triggers popover), popover launches but has no content.
How to reproduce the problem
- Create a new Hugo site and add following files with content as given:
data/icons.yml contains:
windows: "<span class='fab fa-windows'></span>"
layouts/index.html contains:
<!-- Bootstrap stylesheet --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> <!-- Font Awesome stylesheet --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css"> <!-- Scripts required for Bootstrap framework --> <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script> <!-- A popover with Windows icon as its content --> <a role="button" class="btn" tabindex="0" data-toggle="popover" data-trigger="focus" data-html="true" data-original-title="Tablet" data-content=" <span class='fa-2x'>{{ site.Data.icons.windows | safeHTML }}</span> ">Tablet</a> <!-- Enable popovers --> <script> $("[data-toggle='popover']").popover(); </script>
- Now, run
hugo serve
.
Actual output
It may easily be noted that by clicking on Tablet
, popover launches but has no content.
Expected output
The popover should show the Windows icon.
Possible cause
I have found out that I am calling <span class='fa-2x'>{{ site.Data.icons.windows | safeHTML }}</span>
in quotes (of data-content
), so that it renders nothing. If <span class='fa-2x'>{{ site.Data.icons.windows | safeHTML }}</span>
is called not in quotes, then it renders Windows icon. But that is not how it needs to be.
Please help!