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

179
Visualizações
ejs code stored in string wont execute on frontend

I have part of code stored in db as a string. So that would be

var code = "<% if ('undefined' === typeof(store.disable_sharesale_upsellit) || store.disable_sharesale_upsellit == false) { %>

    <% if (typeof(store.settings.shareasale_id) != 'undefined' && '' != store.settings.shareasale_id && typeof(store.settings.allpages_upsellit_snippet_pixel) != 'undefined' && store.settings.allpages_upsellit_snippet_pixel != '') { %>
    <script>
        var shareasale_id = <%- JSON.stringify(store.settings.shareasale_id) %>;
        console.log(shareasale_id);
        console.log('shareasale123');
    </script>
    <% } %>

    <% if (typeof(store.settings.upsellit_id) != 'undefined' && '' != store.settings.upsellit_id && typeof(store.settings.allpages_upsellit_snippet_pixel) != 'undefined' && store.settings.allpages_upsellit_snippet_pixel != '') { %>
    <script type="text/javascript">
      console.log('upsellit');
    </script>
    <% } %>

<% } %>"

Now im passing this variable thru res.view as setting and in the ejs file im trying to pass it like this:

<%- store.settings.code %>

but what im getting is that js console.logs are executed but ejs tags are shown on page as they are in paragraph. Also the console log where ejs tags are present throws error. Not doing the if checkings as it does when the code is written directly in the ejs file. Any hint how to pass ejs code stored as string in the ejs file?

about 4 years ago · Juan Pablo Isaza
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