Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!