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

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

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