我初始化了一个新的Sails
项目并将Jade
设置为模板引擎。此时我还没有任何 Controller 和模型。
下面是layout.jade
中的代码。
doctype html
html
head
title= title
// Viewport mobile tag for sensible mobile support
meta(name="viewport",content="width=device-width, initial-scale=1, maximum-scale=1")
block styles
body
block body
// A few key dependencies, linked in order
// Bring in the socket.io client
script(type="text/javascript", src="/scripts/js/socket.io.js")
// then beef it up with some convenience logic for talking to Sails.js'
script(type="text/javascript", src="/scripts/js/sails.io.js")
// listen on socket.io for incoming messages
script(type="text/javascript", src="/scripts/js/app.js")
在标题标签中:
title= title
我在主页/索引页面和布局中找不到标题变量赋值表达式,路线很简单:
'/': {
view: 'home/index'
}
没有通过任何 Controller 。但是标题编译为
<title>Sails</title>
标题变量的值从哪里来?
最佳答案
看起来它默认为应用程序的名称,这样您就不会出现空白标题。
https://github.com/balderdashy/sails/blob/master/lib/hooks/request/locals.js#L46
关于javascript - 无法找到在 Sails 项目中将变量传递给 Jade title 的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22190185/