twig文件支持html吗,如何从Twig加载CSS / JS / HTML ?

如果您想从您的Twig文件中添加JavaScript、CSS和HTML,您可以这样做:

{# Add assets into head of the document by using default priority. #}

{% assets in 'head' with { priority: 0 } %}

{% endassets -%}

基本上,可以选择两个可选参数:

in 'x'

with { priority: y }

参数x是您想要添加内容的位置(head和footer目前由Hydrogen主题支持),y是优先级,用于命令资产默认为0,范围从-10到10。

优先级较高的数字被添加到文档中,在任何较低的数字之前。如果有多个具有相同优先级的资产标记,则它们的排序没有定义。

还有一个JavaScript的Twig标签:

{# Add javascript into end of the document (before any other javascript in the footer). #}

{% scripts in 'footer' with { priority: 10 } %}

{% endscripts -%}

只适用于样式表:

{# Add some stylesheets and make them to load last (override other styles). #}

{% styles with { priority: -10 } %}

{% endstyles -%}

在Gantry 5.3+中载入CSS / JS

从Gantry 5.3开始,有一种

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值