{"id":19574329,"url":"https://github.com/straticjs/gulp-attach-to-template","last_synced_at":"2026-05-18T06:04:13.560Z","repository":{"id":57256834,"uuid":"72718673","full_name":"straticjs/gulp-attach-to-template","owner":"straticjs","description":"gulp plugin to take a stream of Vinyl files and attach them to a template","archived":false,"fork":false,"pushed_at":"2018-12-17T19:59:39.000Z","size":27,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-18T10:44:19.791Z","etag":null,"topics":["gulp","gulp-plugin","hacktoberfest","javascript","vinyl"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/straticjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-03T07:16:10.000Z","updated_at":"2021-10-07T16:59:22.000Z","dependencies_parsed_at":"2022-08-25T02:40:52.200Z","dependency_job_id":null,"html_url":"https://github.com/straticjs/gulp-attach-to-template","commit_stats":null,"previous_names":["strugee/gulp-attach-to-template"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/straticjs%2Fgulp-attach-to-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/straticjs%2Fgulp-attach-to-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/straticjs%2Fgulp-attach-to-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/straticjs%2Fgulp-attach-to-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/straticjs","download_url":"https://codeload.github.com/straticjs/gulp-attach-to-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240840106,"owners_count":19866168,"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-plugin","hacktoberfest","javascript","vinyl"],"created_at":"2024-11-11T06:39:59.212Z","updated_at":"2026-05-18T06:04:08.493Z","avatar_url":"https://github.com/straticjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `gulp-attach-to-template`\n\n[gulp][1] plugin to take a stream of Vinyl files and attach them to a template\n\n## Why?\n\nThis module is very similar to the excellent [`gulp-apply-template`][2]. It differs in the following ways:\n\n1. It's version is \u003e=1.0.0, so semver is more useful\n2. Its usage is simpler\n3. It doesn't use [consolidate.js][3] and instead expects you to render templates yourself (this also means it pulls the template from the file stream instead of reading it directly, which is a \\[admittedly widespread] [gulp antipattern][4])\n\nThese items are a matter of personal preference, to varying degrees. Feel free to use `gulp-apply-template` if you think that style is more readable, although be aware that `gulp-apply-template` [appears to be unmaintained](https://github.com/straticjs/gulp-attach-to-template/issues/4).\n\n## Installation\n\n    npm install gulp-attach-to-template\n\n## Example\n\nMinimal example:\n\n```js\nvar gulp = require('gulp');\nvar attachToTemplate = require('gulp-attach-to-template');\nvar addsrc = require('gulp-add-src');\n\ngulp.task('template', function() {\n\treturn gulp.src('*.md')\n\t           .pipe(addsrc('template.jade'))\n\t           .pipe(attachToTemplate('template.jade'));\n});\n```\n\nFull example:\n\n```js\nvar gulp = require('gulp');\nvar remark = require('gulp-remark');\nvar remarkHtml = require('remark-html');\nvar attachToTemplate = require('gulp-attach-to-template');\nvar addsrc = require('gulp-add-src');\nvar jade = require('gulp-jade');\nvar rename = require('gulp-rename');\n\ngulp.task('template', function() {\n\treturn gulp.src('*.md')\n\t           .pipe(remark().use(remarkHtml))\n\t           .pipe(addsrc('template.jade'))\n\t           .pipe(attachToTemplate('template.jade'))\n\t           .pipe(jade({basedir: __dirname}))\n\t           .pipe(rename({ extname: '.html' }))\n\t           .pipe(gulp.dest('dist'));\n});\n```\n\nWhat's happening here? First we read in some Markdown files from disk and render them to HTML. Then we add `template.jade` into the stream of files. `template.jade` is what will be used for the template.\n\nWhen we pipe all the files to `attachToTemplate`, we pass it the name of the template file. From there, `gulp-attach-to-template` will output copies of this template, one for each file. The Vinyl file object will be available to the template as the `file` local, and the template copy's `path` will be set to the `path` of its `file` local. (That is, each template copy will inherit the Vinyl path of whatever's attached to it.)\n\nThe rest is just standard gulp: we render the Jade, rename the templates to `.html` files, and write to the `dist` directory.\n\n## License\n\nLGPL 3.0+\n\n## Author\n\nAJ Jordan \u003calex@strugee.net\u003e\n\n [1]: http://gulpjs.com/\n [2]: https://www.npmjs.com/package/gulp-apply-template/\n [3]: https://github.com/tj/consolidate.js\n [4]: https://github.com/gulpjs/gulp/issues/357\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstraticjs%2Fgulp-attach-to-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstraticjs%2Fgulp-attach-to-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstraticjs%2Fgulp-attach-to-template/lists"}