[英]Can't find out where passing variable to Jade title in Sails project
I initial a new Sails
project and set Jade
as template engine. 我初始化一个新的
Sails
项目并将Jade
设置为模板引擎。 At this time I don't have any controller and model. 这时我没有任何控制器和模型。
Below is the code in layout.jade
. 下面是
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")
In title tag: 在标题标签中:
title= title
I couldn't find out the title variable assign expression in home/index page & layout, and route is simple: 我无法在home / index页面和布局中找到title变量赋值表达式,并且路由很简单:
'/': {
view: 'home/index'
}
Didn't through any controller.But title compile to 没有通过任何控制器。但标题编译到
<title>Sails</title>
Where is the title variable's value come from? title变量的值来自哪里?
It looks like it defaults to the application's name so that you never have a blank title. 它看起来默认为应用程序的名称,因此您永远不会有空白标题。
https://github.com/balderdashy/sails/blob/master/lib/hooks/request/locals.js#L46 https://github.com/balderdashy/sails/blob/master/lib/hooks/request/locals.js#L46
I'm setting my page title through the /config/routes.js like this. 我正在通过/config/routes.js设置我的页面标题。
'get /': {
view: 'homepage',
locals: {
page: {
title: 'Home'
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.