I initial a new Sails
project and set Jade
as template engine. At this time I don't have any controller and model.
Below is the code in 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:
'/': {
view: 'home/index'
}
Didn't through any controller.But title compile to
<title>Sails</title>
Where is the title variable's value come from?
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
I'm setting my page title through the /config/routes.js like this.
'get /': {
view: 'homepage',
locals: {
page: {
title: 'Home'
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.