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

178
Vistas
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 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