https://github.com/reisraff/phulp-inject
The inject addon for phulp
https://github.com/reisraff/phulp-inject
inject php phulp phulp-inject phulpplugin
Last synced: 4 months ago
JSON representation
The inject addon for phulp
- Host: GitHub
- URL: https://github.com/reisraff/phulp-inject
- Owner: reisraff
- License: mit
- Created: 2016-10-27T18:36:08.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-01-27T19:09:26.000Z (about 5 years ago)
- Last Synced: 2025-01-18T05:14:24.249Z (over 1 year ago)
- Topics: inject, php, phulp, phulp-inject, phulpplugin
- Language: PHP
- Homepage: https://github.com/reisraff/phulp
- Size: 14.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# phulp-inject
The inject addon for [PHULP](https://github.com/reisraff/phulp).
It's like [gulp-inject](https://github.com/klei/gulp-inject) with some modifications.
## Install
```bash
$ composer require reisraff/phulp-inject
```
## Usage
**The target file `src/index.html`:**
Each pair of comments are the injection placeholders
```html
App
```
**The `phulpfile.php`:**
```php
task('inject', function ($phulp) {
$injectionFiles = $phulp->src(['src/'], '/(js|css)$/', true);
$phulp->src(['src/'], '/html$/')
// injecting
->pipe(new Inject($injectionFiles->getDistFiles()))
// write the html file with the injected files
->pipe($phulp->dest('dist/'));
});
```
**`dist/index.html` after running `phulp inject`:**
```html
App
```
## Options
Set in the constructor.
***tagname*** : default: inject, it is used to define a global tagname as placeholder.
***starttag*** : default: null, it is used to replace the default starttag
***endtag*** : default: null, it is used to replace the default endtag
***filterFilename*** : default: null, it is used to replace the filename
```php
'replace-inject',
'starttag' => '<-- replace-inject -->',
'endtag' => '<-- endreplace-inject -->,
'filterFilename' => function ($filename) {
return 'path/' . $filename;
},
]
);
```