An open API service indexing awesome lists of open source software.

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

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;
},
]
);

```