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

135
Vistas
Can gulp-ejs be used dynamically?

There is a project, layout of the admin panel with numerous components. There is a folder of components, to use them, I use the gulp-ejs plugin and do it like this: <%- include('../components/buttons/_success') %> Naturally, the button has the same text wherever this component is included, and I want to make its text dynamic, for example, I import it into the navigation and change the text. As an example, you can take a react, where instead of the static text of the component, they put some kind of props.title. Please help me how to implement this using gulp-ejs. As you already guessed, the project is built using the gulp builder, clean layout, without any express-js

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

After a while, I did find a way, for this you can use the "gulp-file-include":

  1. Install package:

npm i gulp-file-include 2. Import it into the gulp configuration file (in my case it is the gulpfile.js file)

const include = require('gulp-file-include');

  1. Use it when generating html:

function html() {
return src([sourceFolder + '/html/**.html', sourceFolder + '/html/*.htaccess'])
.pipe(include())
...
}

  1. Let's say there is a template for a button, and you want to pass text there dynamically, for this you use @@ to declare a variable, the value of which can be changed through the parent:

button.html:

<button class="btn">@@content</button>
  1. Now to use the button component in another file and to change its text you need to pass the second parameter when importing:

index.html:

<div>
  @@include('button.html', { "content" : "Send"})
<div>

It is important to specify the correct path to the component in the first parameter

Ready! Now you have the button text dynamically changing, for a more detailed study, here is a link with a library and documentation

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