Skip to content

Instantly share code, notes, and snippets.

@nahanil
Last active September 8, 2019 19:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nahanil/c04539266a67cd33a80dd38267853926 to your computer and use it in GitHub Desktop.
Save nahanil/c04539266a67cd33a80dd38267853926 to your computer and use it in GitHub Desktop.
Sails page title
<!DOCTYPE html>
<html lang="en">
<head>
<title><%= typeof data !== 'undefined' && data.title ? data.title + ' | ' : (typeof title == 'undefined' ? '' : title + " | " )%><%= sails.config.appName %> | Chinese - English Dictionary &amp; Mandarin Learning Resources</title>
...
module.exports.routes = {
'GET /foo': { action: 'something', locals: { title: 'Foo Title thingy' } }
}
return exits.success({ title: 'Action page title thingy' })
res.locals.title = 'Hook title'
@Noitidart
Copy link

Noitidart commented Sep 7, 2019

Is it possible to control locals from exists in actions2 controller?
The above is already perfect I'm just nit picking to learn. The above I used, I just changed the ternary in layout to:

<% if(title) { %>
  <title><%= title %> - Website</title>
<% } else { %>
  <title>Website</title>
<% } %>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment