追加头在 Jade 中不起作用 [英] append head doesn't work in Jade
本文介绍了追加头在 Jade 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的layout.jade
如下:
doctype html
html
head
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
link(rel='stylesheet', href='/stylesheets/bootstrap.css')
link(rel='stylesheet', href='/stylesheets/bootstrap-grid.css')
link(rel='stylesheet', href='/stylesheets/bootstrap-reboot.css')
script(src="/javascripts/core.js")
script(src="/javascripts/jquery.js")
script(src="/javascripts/jquery-slim.js")
script(src="/javascripts/bootstrap.js")
body
block content
我的 place.jade
如下:
extends layout
append head
script(src="/javascripts/custom.js")
...
当我服务模板时,我看到
When I serve templete, I see
这意味着追加根本不呈现.
Which meand appending doesn't render at all.
为什么?
推荐答案
Append 只对 block 起作用,所以 layout.jade 的正确代码是
Append works only with block so the correct code of layout.jade is
doctype html
html
head
block scripts
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
link(rel='stylesheet', href='/stylesheets/bootstrap.css')
link(rel='stylesheet', href='/stylesheets/bootstrap-grid.css')
link(rel='stylesheet', href='/stylesheets/bootstrap-reboot.css')
script(src="/javascripts/core.js")
script(src="/javascripts/jquery.js")
script(src="/javascripts/jquery-slim.js")
script(src="/javascripts/bootstrap.js")
body
block content
对于 place.jade 将是
and for place.jade will be
extends layout
append scripts
script(src="/javascripts/custom.js")
...
这篇关于追加头在 Jade 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文