Is there anyway to write and if statement for an include.
{% if include showcase.html%}
add script tag
{% endif %}
thanks in advance
Is there anyway to write and if statement for an include.
{% if include showcase.html%}
add script tag
{% endif %}
thanks in advance
Couldn’t you put the script tag in the include?
When the include is added to a page the script comes along for the ride. When it’s not it’s not.
but the script will be called before jquery so ideally i want that to sit at the bottom of the page
You can place the “include” at the bottom of your template:
[...]
{% include script.html %}
</body>
</html>
Ah gotcha. That might be tricky then. Perhaps you could move just jQuery to the <head>
so any plugins or scripts that depend on it could load after.
It’s not as performant as you alluded to by wanting them further down the page, presumably before the closing </body>
element.
Not sure if this would work, but maybe something like:
_includes/showcase.html:
{% assign showcase_visible = true %}
<!-- showcase HTML and logic -->
in your layout:
<!-- layout stuff -->
{{ content }}
<!-- placed near the bottom
checks for showcase_visible variable from include
-->
{% if showcase_visible == true %}
<script>
showcase JavaScript
</script>
{% endif %}
in the page:
Some content here.
{% include showcase.html %}
this makes sense I will try this