{"id":23012967,"url":"https://github.com/meeroslav/gulp-inject-partials","last_synced_at":"2025-08-14T06:32:45.015Z","repository":{"id":57257880,"uuid":"56134788","full_name":"meeroslav/gulp-inject-partials","owner":"meeroslav","description":"A recursive injection of partials based on their path name. Implementation of specific case of gulp-inject.","archived":false,"fork":false,"pushed_at":"2019-03-25T10:26:23.000Z","size":40,"stargazers_count":26,"open_issues_count":1,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-14T09:17:25.334Z","etag":null,"topics":["gulp","gulp-inject-partials","html","injection","partials"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meeroslav.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-13T08:32:51.000Z","updated_at":"2024-11-05T16:16:11.000Z","dependencies_parsed_at":"2022-08-25T21:22:47.753Z","dependency_job_id":null,"html_url":"https://github.com/meeroslav/gulp-inject-partials","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meeroslav%2Fgulp-inject-partials","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meeroslav%2Fgulp-inject-partials/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meeroslav%2Fgulp-inject-partials/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meeroslav%2Fgulp-inject-partials/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meeroslav","download_url":"https://codeload.github.com/meeroslav/gulp-inject-partials/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229690066,"owners_count":18108151,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gulp","gulp-inject-partials","html","injection","partials"],"created_at":"2024-12-15T10:20:29.262Z","updated_at":"2024-12-15T10:20:59.792Z","avatar_url":"https://github.com/meeroslav.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gulp-inject-partials\n\n[![NPM version][npm-image]][npm-url]\n[![Build Status][travis-image]][travis-url]\n[![Dependency Status][depstat-image]][depstat-url]\n[![Code Climate][codeclimate-image]][codeclimate-url]\n\n\u003e A recursive injection of partials based on their path name for [gulp](https://github.com/wearefractal/gulp).\n\n**Gulp-inject-partials** parses target file, located defined placeholders and injects file contents based on their relative path. See [Basic usage](#basic-usage) and [More examples](#more-examples) below.\nGulp-inject-partials is based/inspired by [`gulp-inject`](https://github.com/klei/gulp-inject).\n\n**Note:** NodeJs v4 or above is required.\n\n## Installation\n\nInstall `gulp-inject-partials` as a development dependancy:\n\n```shell\nnpm install --save-dev gulp-inject-partials\n```\n\n## Basic usage\n\nEach pair of comments are the injection placeholders (aka. tags, see [`options.start`](#optionsstart) and [`options.end`](#optionsend)).\n\n**index.html**\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n  \u003ctitle\u003eMy index\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003c!-- partial:partial/_mypartial.html --\u003e\n  \u003c!-- partial --\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n**partial/_mypartial.html**\n```html\n\u003cdiv\u003e\n  This text is in partial\n\u003c/div\u003e\n```\n**gulpfile.js**\n```javascript\nvar gulp = require('gulp');\nvar injectPartials = require('gulp-inject-partials');\n\ngulp.task('index', function () {\n  return gulp.src('./src/index.html')\n           .pipe(injectPartials())\n           .pipe(gulp.dest('./src'));\n});\n```\n**Results in**\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n  \u003ctitle\u003eMy index\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003c!-- partial:views/_mypartial.html --\u003e\n  \u003cdiv\u003e\n  This text is in partial\n\u003c/div\u003e\n  \u003c!-- partial --\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n## More examples\n\n### Injecting nested partials\n\nNesting partials works same way as single level injection. When injecting partials, `gulp-inject-partials` will parse parent file in search for partials to inject. Once it finds a partial will then recursively parse child partial.\n\n**index.html**\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n  \u003ctitle\u003eMy index\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003c!-- partial:views/_mypartial.html --\u003e\n  \u003c!-- partial --\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n**views/_mypartial.html**\n```html\n\u003cdiv\u003e\n  This is in partial\n  \u003c!-- partial:_mypartial2.html --\u003e\n  \u003c!-- partial --\u003e\n  \u003c!-- partial:_mypartial3.html --\u003e\n  \u003c!-- partial --\u003e\n\u003c/div\u003e\n```\n**views/_mypartial2.html**\n```html\n\u003cdiv\u003e\n  This text is in partial 2\n\u003c/div\u003e\n```\n**views/_mypartial3.html**\n```html\n\u003cdiv\u003e\n  This text is in partial 3\n\u003c/div\u003e\n```\n**gulpfile.js**\n```javascript\nvar gulp = require('gulp');\nvar injectPartials = require('gulp-inject-partials');\n\ngulp.task('index', function () {\n  return gulp.src('./src/index.html')\n           .pipe(injectPartials())\n           .pipe(gulp.dest('./src'));\n});\n```\n**Results in**\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n  \u003ctitle\u003eMy index\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003c!-- partial:views/_mypartial.html --\u003e\n  \u003cdiv\u003e\n  This is in partial\n  \u003c!-- partial:_mypartial2.html --\u003e\n  \u003cdiv\u003e\n  This text is in partial 2\n\u003c/div\u003e\n  \u003c!-- partial --\u003e\n  \u003c!-- partial:_mypartial3.html --\u003e\n  \u003cdiv\u003e\n  This text is in partial 3\n\u003c/div\u003e\n  \u003c!-- partial --\u003e\n\u003c/div\u003e\n  \u003c!-- partial --\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Setting the custom `start` and/or `end` tag\n\nIt's possible to change start and end tag by setting [`option.start`](#optionsstart) and [`options.end`](#optionsend) respectivelly.\n\n**index.html**\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n  \u003ctitle\u003eMy index\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003c## partial/_mypartial.html\u003e\n  \u003c/##\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n**partial/_mypartial.html**\n```html\n\u003cdiv\u003e\n  This text is in partial\n\u003c/div\u003e\n```\n**gulpfile.js**\n```javascript\nvar gulp = require('gulp');\nvar injectPartials = require('gulp-inject-partials');\n\ngulp.task('index', function () {\n  return gulp.src('./src/index.html')\n           .pipe(injectPartials({\n              start: '\u003c## {{path}}\u003e',\n              end: '\u003c/##\u003e'\n           }))\n           .pipe(gulp.dest('./src'));\n});\n```\n**Results in**\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n  \u003ctitle\u003eMy index\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003c!-- partial:views/_mypartial.html --\u003e\n  \u003cdiv\u003e\n  This text is in partial\n\u003c/div\u003e\n  \u003c!-- partial --\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Remove tags after insertion\n\nFor production purposes we would like inject tags to be removed and have a clean html. This is possible with [`options.removeTags`](#optionsremovetags).\n\n**index.html**\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n  \u003ctitle\u003eMy index\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003c!-- partial:partial/_mypartial.html --\u003e\n  \u003c!-- partial --\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n**partial/_mypartial.html**\n```html\n\u003cdiv\u003e\n  This text is in partial\n\u003c/div\u003e\n```\n**gulpfile.js**\n```javascript\nvar gulp = require('gulp');\nvar injectPartials = require('gulp-inject-partials');\n\ngulp.task('index', function () {\n  return gulp.src('./src/index.html')\n           .pipe(injectPartials({\n              removeTags: true\n           }))\n           .pipe(gulp.dest('./src'));\n});\n```\n**Results in**\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n  \u003ctitle\u003eMy index\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003cdiv\u003e\n  This text is in partial\n\u003c/div\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n## API\n\n### inject(options)\n\n#### options.start\nType: `string`  \nParam (optional): `path` - relative path to source file  \nDefault: `\u003c!-- partial:{{path}} --\u003e`  \nUsed to dynamically set starting placeholder tag, which might contain relative `path` to source file. Even thou this parameter is optional, whithout it no file would be injected.\n\n#### options.end\nType: `string`  \nParam (optional): `path` - relative path to source file     \nDefault: `\u003c!-- partial --\u003e`  \nUsed to dynamically set ending placeholder tag, which might contain relative `path` to source file.\n\n#### options.removeTags\nType: `boolean`  \nDefault: false  \nWhen `true` the start and end tags will be removed when injecting files.\n\n#### options.quiet\nType: `boolean`  \nDefault: false  \nWhen `true` gulp task will not render any information to console.\n\n#### options.prefix\nType: `string`  \nDefault: (Empty string)  \nPrefix path to prepend to every route processed e.g. `relative/path/to/partials/`. Note that full route is still relative.\n\n#### options.ignoreError\nType: 'boolean'\nDefault: false\nWhen `true` ignores missing files during the injection and shows just info message \n\n## License\n\n[MIT](http://en.wikipedia.org/wiki/MIT_License) © [Miroslav Jonas](mailto:meeroslav@yahoo.com)\n\n[npm-url]: https://npmjs.org/package/gulp-inject-partials\n[npm-image]: https://img.shields.io/npm/v/gulp-inject-partials.png\n\n[travis-url]: http://travis-ci.org/meeroslav/gulp-inject-partials\n[travis-image]: https://travis-ci.org/meeroslav/gulp-inject-partials.svg?branch=master\n\n[depstat-url]: https://david-dm.org/meeroslav/gulp-inject-partials\n[depstat-image]: https://david-dm.org/meeroslav/gulp-inject-partials.png\n\n[codeclimate-url]: https://codeclimate.com/github/meeroslav/gulp-inject-partials\n[codeclimate-image]: https://codeclimate.com/github/meeroslav/gulp-inject-partials/badges/gpa.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeeroslav%2Fgulp-inject-partials","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeeroslav%2Fgulp-inject-partials","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeeroslav%2Fgulp-inject-partials/lists"}