{"id":15732453,"url":"https://github.com/jonschlinkert/gulp-layouts","last_synced_at":"2026-05-05T21:35:46.258Z","repository":{"id":57258101,"uuid":"64182846","full_name":"jonschlinkert/gulp-layouts","owner":"jonschlinkert","description":"Gulp plugin for the `layouts` library, which provides a simple way of \"wrapping\" a string with common code or content.","archived":false,"fork":false,"pushed_at":"2016-07-26T02:40:07.000Z","size":7,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-23T04:11:14.468Z","etag":null,"topics":["gulp","gulpplugin","javascript","layout","layouts","nodejs","plugin","render","template"],"latest_commit_sha":null,"homepage":"","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/jonschlinkert.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-07-26T02:21:05.000Z","updated_at":"2021-04-12T22:34:21.000Z","dependencies_parsed_at":"2022-08-25T21:23:41.781Z","dependency_job_id":null,"html_url":"https://github.com/jonschlinkert/gulp-layouts","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fgulp-layouts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fgulp-layouts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fgulp-layouts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fgulp-layouts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/gulp-layouts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246413230,"owners_count":20773053,"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","gulpplugin","javascript","layout","layouts","nodejs","plugin","render","template"],"created_at":"2024-10-04T00:20:27.034Z","updated_at":"2026-05-05T21:35:46.224Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gulp-layouts [![NPM version](https://img.shields.io/npm/v/gulp-layouts.svg?style=flat)](https://www.npmjs.com/package/gulp-layouts) [![NPM downloads](https://img.shields.io/npm/dm/gulp-layouts.svg?style=flat)](https://npmjs.org/package/gulp-layouts) [![Build Status](https://img.shields.io/travis/jonschlinkert/gulp-layouts.svg?style=flat)](https://travis-ci.org/jonschlinkert/gulp-layouts)\n\nGulp plugin for the `layouts` lib, which provides a simple way of using common code or content to wrap other files. Can be used with HTML, javascript, banners, CSS, or any other string.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save gulp-layouts\n```\n\n## What is a layout?\n\nA layout is a template that is used to \"wrap\" other files with common content or code.\n\n**Example**\n\nGiven you have a layout, `default.txt` with the following contents:\n\n```\nfoo\n{% body %}\nbar\n```\n\nIf you specify the name of the layout on the `file.layout` property, like so:\n\n```js\nvar File = require('vinyl');\nvar file = new File({path: 'foo/bar.txt', contents: new Buffer('This is contents')});\nfile.layout = 'default.txt';\n```\n\nThen pass the layout to the `layouts()` plugin:\n\n```js\nvar layout = new File({path: 'default.txt', contents: new Buffer('foo\\n{% body %}\\nbar')});\n\ngulp.task('default', function() {\n  return gulp.src('test/fixtures/alpha.txt')\n    .pipe(layouts({files: {'default.txt': layout}}))\n    .pipe(gulp.dest('test/actual'));\n});\n```\n\n**Results in:**\n\n```\nfoo\nThis is contents\nbar\n```\n\nVisit [layouts](https://github.com/doowb/layouts) for more examples. The unit tests are really helpful as well.\n\n## Usage\n\nPass an object of vinyl files on `options.files` for the plugin to use as \"layouts\":\n\n* the contents of each file must have a `{% body %}` tag. See the [layouts](https://github.com/doowb/layouts) docs if you need to customize this.\n* layouts can specify other layouts\n* a default layout can be specified on `options.defaultLayout`\n\n## Examples\n\n### Apply banners\n\nGiven you have a javascript file, `index.js`, with the following contents:\n\n```js\nmodule.exports = function() {\n};\n```\n\n**Define layouts**\n\nand this banner, in `banner.js`:\n\n```js\n/*!\n * \u003c%= name %\u003e \u003c\u003c%= homepage %\u003e\u003e\n *\n * Copyright (c) \u003c%= year %\u003e, \u003c%= author %\u003e.\n * Licensed under the MIT License.\n */\n```\n\nYou can easily create a layout to apply banners to any files:\n\n```js\nvar fs = require('fs');\nvar gulp = require('gulp');\nvar layouts = require('gulp-layouts');\n\nvar files = {banner: {contents: fs.readFileSync('banner.js')}};\nvar data = require('./package');\ndata.year = new Date().getFullYear();\n\ngulp.task('default', function() {\n  return gulp.src('test/fixtures/alpha.txt')\n    .pipe(layouts({files: files, defaultLayout: 'banner'}))\n    .pipe(template(data))\n    .pipe(gulp.dest('test/actual'));\n});\n```\n\n**Results in something like:**\n\n```js\n/*!\n * your-package \u003chttps://github.com/foo/your-package\u003e\n *\n * Copyright (c) 2016, Santa Claus.\n * Licensed under the MIT License.\n */\nmodule.exports = function() {\n};\n```\n\n### Nested layouts\n\nGiven you have a file, `alpha.txt`, with the following contents:\n\n```\nThis is the alpha file!\n```\n\n**Define layouts**\n\n```js\nvar gulp = require('gulp');\nvar layouts = require('gulp-layouts');\n\nvar files = {\n  aaa: {contents: new Buffer('aaa before\\n{% body %}\\naaa after'), layout: 'bbb'},\n  bbb: {contents: new Buffer('bbb before\\n{% body %}\\nbbb after'), layout: 'ccc'},\n  ccc: {contents: new Buffer('ccc before\\n{% body %}\\nccc after')},\n};\n\ngulp.task('default', function() {\n  return gulp.src('test/fixtures/alpha.txt')\n    .pipe(layouts({files: files}))\n    .pipe(gulp.dest('test/actual'));\n});\n```\n\n**Results in:**\n\nThe contents of `alpha.txt` is updated to:\n\n```\nccc before\nbbb before\naaa before\nThis is the alpha file!\naaa after\nbbb after\nccc after\n```\n\n## About\n\n### Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n### Building docs\n\n_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_\n\nTo generate the readme and API documentation with [verb](https://github.com/verbose/verb):\n\n```sh\n$ npm install -g verb verb-generate-readme \u0026\u0026 verb\n```\n\n### Running tests\n\nInstall dev dependencies:\n\n```sh\n$ npm install -d \u0026\u0026 npm test\n```\n\n### Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT license](https://github.com/jonschlinkert/gulp-layouts/blob/master/LICENSE).\n\n***\n\n_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on July 25, 2016._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fgulp-layouts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Fgulp-layouts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fgulp-layouts/lists"}