Possible to dynamically inject files depends on the name of file to be injected ?
See original GitHub issueI have a huge HTML file, with many files to inject, but it seems not DRY to do this:
var myTransform = function (filepath, file) {
return file.contents.toString('utf8');
};
gulp.src('target.html')
.pipe(inject(gulp.src('file1.html'), { starttag: '<!-- inject:file1:html} -->'), transform: myTransform))
.pipe(inject(gulp.src('file2.html'), { starttag: '<!-- inject:file2:html} -->'), transform: myTransform))
.pipe(inject(gulp.src('file3.html'), { starttag: '<!-- inject:file3:html} -->'), transform: myTransform))
.pipe(inject(gulp.src('file4.html'), { starttag: '<!-- inject:file4:html} -->'), transform: myTransform))
.pipe(inject(gulp.src('file5.html'), { starttag: '<!-- inject:file5:html} -->'), transform: myTransform))
.pipe(inject(gulp.src('file6.html'), { starttag: '<!-- inject:file6:html} -->'), transform: myTransform))
.pipe(inject(gulp.src('file7.html'), { starttag: '<!-- inject:file7:html} -->'), transform: myTransform))
.pipe(inject(gulp.src('file8.html'), { starttag: '<!-- inject:file8:html} -->'), transform: myTransform))
.pipe(inject(gulp.src('file9.html'), { starttag: '<!-- inject:file9:html} -->'), transform: myTransform))
;
Any way to eliminate the duplication? Thanks!
Issue Analytics
- State:
- Created 9 years ago
- Reactions:2
- Comments:12 (2 by maintainers)
Top Results From Across the Web
java - Is it possible to dynamically manage @Named injection ...
This is a possible solution for you using IterableProvider (which has a "named" method on it to choose a specific named version at...
Read more >Dynamic-link Library Injection, Sub-technique T1055.001 ...
ID Name Description
S0024 Dyre Dyre injects into other processes to load modules.
S0081 Elise Elise injects DLL files into iexplore.exe.
S0613 PS1 PS1 can inject...
Read more >Require file dynamically by variable · Issue #6391 - GitHub
I want to require files like: var component = require("myApp/components/" + name); Seems like require wants passed string to be static, not dependent...
Read more >Loading Script Files Dynamically - KIRUPA
Mainly, we have a script element that contains some code to dynamically load a file called easing.js and append it to the bottom...
Read more >Dependency injection in Android | Android Developers
These required classes are called dependencies, and in this example the Car class is dependent ... so constructor injection is not possible.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
+1 here as well. Would be great if we could do something like:
Same here. I really prefer @JustMaier 's way which includes a
{{filename}}
option: