我正在尝试使用jade模板创建一个模块化布局。我想从子元素向其父级的父级中添加一个脚本块。我不确定是否可能。
这是我的结构
layout.jade
head.jade
index.jade
users.jade
layout.jade: doctype html#html include head
body
block content
head.jade:
head
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
block scripts
index.jade:
extends layout
block content
h1 Hello
include users
users.jade
block append scripts
script(src='/javascripts/user.js')
ul
each user, i in users
li(class=i+"-"+user) #{user}
我期望得到的HTML输出应该是:
<!DOCTYPE html>
<html id="html">
<head>
<title>Index</title>
<link href="/stylesheets/style.css" rel="stylesheet">
<script src="/javascripts/user.js">