追加头并不适用于翡翠

时间:2017-06-16 09:48:10

标签: javascript node.js pug

我的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")
    ...

当我为templete服务时,我看到了

enter image description here

哪个meand追加都没有呈现。

为什么?

1 个答案:

答案 0 :(得分:2)

追加仅适用于块,因此layout.jade的正确代码为

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将是

extends layout

append scripts
    script(src="/javascripts/custom.js")
    ...