Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
Sails set css in specific page

I'm using the sails.js framework

I want to know if there is a way for a view to use only one css file, not the other ones being declared in the layout?

That is, ignore the other css definitions and use only one.

Is that possible?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Yes. Inside of the method that renders your view, return a value that references the stylesheet you want to include.

return res.view('someTemplate',{
    myStylesheet: 'link/to/your/stylesheet.css'
})

Then, edit your layout.ejs file to include the stylesheet if our new value is present.

<!DOCTYPE html>
    <html>
      <head>
        <title><%= title %></title>
        ...

        <% if(myStylesheet) { %>
        <link rel="stylesheet" href="<%= myStylesheet %>">
        <% } %>

        <!--STYLES-->
        <link rel="stylesheet" href="/some/other/stylesheet.css">
        <!--STYLES END--> 
        ...
    ...
...

The EJS template pre-processor will now only include the stylesheet you specify if a value is provided.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!