Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

157
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda