只是想知道为什么液体包含声明似乎没有看到网址中有链接?
YAML前线
javascript:
- https://external.js
- local-script.js
页脚文件:
{% if page.javascript %}
{% for script in page.javascript %}
{% if page.javascript contains "://" %}
<script src="{{ script }}"></script>
{% else %}
<script src="{{ script | prepend: '/assets/js/' | relative_url }}"></script> cat
{% endif %}
{% endfor %}
{% endif %}
输出
<script src="/assets/js/https://external.js"></script> "cat"
<script src="/assets/js/local-script.js"></script> "cat"
答案 0 :(得分:1)
YAML前端问题认为您创建了一个名为https
的变量,其值为//external.js
。您可以通过调用{{ page.javascript.https }}
来测试它,看看它是否返回//external
。解决方案是编写YAML前端字符串,如下所示:
javascript:
- 'https://external.js'
- 'local-script.js'