append head doesn't work in Jade

蹲街弑〆低调 提交于 2019-12-12 05:41:01

问题


My layout.jade is following:

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

My place.jade is following:

extends layout

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

When I serve templete, I see

Which meand appending doesn't render at all.

Why?


回答1:


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

and for place.jade will be

extends layout

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


来源:https://stackoverflow.com/questions/44586130/append-head-doesnt-work-in-jade

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!