Sails uses ejs-locals
in its view rendering, so you can accomplish what you want with blocks.
In your layout.ejs
file, underneath the <!--SCRIPTS END-->
, add (for example):
<%- blocks.localScripts %>
Then in the view you're serving at /locations/map
, call the block with your script tag, for example:
<% block('localScripts', '<script src="https://maps.googleapis.com/maps/api/js"></script>') %>
As an alternative, you could put the <!--SCRIPTS-->
and <!--SCRIPTS END-->
tags in the <head>
of your layout, and then add your view-specific scripts directly into your view rather than using blocks. This is a fine option if you don't mind waiting for those linked scripts to load before your page content is displayed.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…