Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

163
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda