klei / klei/gulp-inject

Possible to dynamically inject files depends on the name of file to be injected ?

Open
#80 12 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
807
Forks
90
PR merge metrics
No merged PRs in 30d

Description

I have a huge HTML file, with many files to inject, but it seems not DRY to do this:

``` javascript
var myTransform = function (filepath, file) {
return file.contents.toString('utf8');
};
gulp.src('target.html')
.pipe(inject(gulp.src('file1.html'), { starttag: ''), transform: myTransform))
.pipe(inject(gulp.src('file2.html'), { starttag: ''), transform: myTransform))
.pipe(inject(gulp.src('file3.html'), { starttag: ''), transform: myTransform))
.pipe(inject(gulp.src('file4.html'), { starttag: ''), transform: myTransform))
.pipe(inject(gulp.src('file5.html'), { starttag: ''), transform: myTransform))
.pipe(inject(gulp.src('file6.html'), { starttag: ''), transform: myTransform))
.pipe(inject(gulp.src('file7.html'), { starttag: ''), transform: myTransform))
.pipe(inject(gulp.src('file8.html'), { starttag: ''), transform: myTransform))
.pipe(inject(gulp.src('file9.html'), { starttag: ''), transform: myTransform))
;
```

Any way to eliminate the duplication? Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the plugin's injection-marker handling and the repeated gulp.src/inject calls shown in the issue. Determine how a marker name could relate to its source file, then identify the relevant tests or entry point and define completion as removing the duplicated pipeline setup while preserving each file's injected content.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.