Skip to content

Instantly share code, notes, and snippets.

@nahanil nahanil/layout.ejs
Last active Sep 8, 2019

Embed
What would you like to do?
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

This comment has been minimized.

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
You can’t perform that action at this time.