Bil*_*oon 54 variables templates pug
我使用模板作为基础,并希望它知道在使用它的页面中设置的一些变量...
文件:template.jade
vars = vars || {some:"variables"}
!!! 5
head
title vars.some
Run Code Online (Sandbox Code Playgroud)
文件:page.jade
vars = {some:"things"} //- this does not get used from within template.jade
extends template
Run Code Online (Sandbox Code Playgroud)
我希望编译的page.jade有一个标题"东西"
Rom*_*rov 116
我在这里找到解决方案
用变量传递块
template.jade:
!!!
html
block vars
head
title #{pageTitle} - default www title
body
Run Code Online (Sandbox Code Playgroud)
page.jade
extends template
block vars
- var pageTitle = 'Home'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20534 次 |
| 最近记录: |