{"_id":"init-file-loader","_rev":"95798","name":"init-file-loader","description":"Loader for Template, for loading files onto a custom view collection inside a vinyl plugin.","dist-tags":{"latest":"0.1.1"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"time":{"modified":"2021-06-03T10:31:58.000Z","created":"2015-04-29T09:11:34.511Z","0.1.1":"2015-04-29T09:18:38.739Z","0.1.0":"2015-04-29T09:11:34.511Z"},"users":{},"author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git://github.com/jonschlinkert/init-file-loader.git"},"versions":{"0.1.1":{"name":"init-file-loader","description":"Loader for Template, for loading files onto a custom view collection inside a vinyl plugin.","version":"0.1.1","homepage":"https://github.com/jonschlinkert/init-file-loader","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git://github.com/jonschlinkert/init-file-loader.git"},"bugs":{"url":"https://github.com/jonschlinkert/init-file-loader/issues"},"license":{"type":"MIT","url":"https://github.com/jonschlinkert/init-file-loader/blob/master/LICENSE"},"files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{},"devDependencies":{"mocha":"*","should":"*"},"keywords":[],"gitHead":"095d8de14405054525f468f61348a5ec6d7e7c36","_id":"init-file-loader@0.1.1","_shasum":"4598a3b4d9c5bb2004250d5aa36c21f29ff65cbb","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"4598a3b4d9c5bb2004250d5aa36c21f29ff65cbb","size":2817,"noattachment":false,"key":"/init-file-loader/-/init-file-loader-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/init-file-loader/download/init-file-loader-0.1.1.tgz"},"directories":{},"publish_time":1430299118739,"_cnpm_publish_time":1430299118739,"_hasShrinkwrap":false},"0.1.0":{"name":"init-file-loader","description":"Loader for Template, for loading files onto a custom view collection inside a vinyl plugin.","version":"0.1.0","homepage":"https://github.com/jonschlinkert/init-file-loader","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git://github.com/jonschlinkert/init-file-loader.git"},"bugs":{"url":"https://github.com/jonschlinkert/init-file-loader/issues"},"license":{"type":"MIT","url":"https://github.com/jonschlinkert/init-file-loader/blob/master/LICENSE"},"files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{},"devDependencies":{"mocha":"*","should":"*"},"keywords":[],"_id":"init-file-loader@0.1.0","_shasum":"57e4cd5da492b94a5bc5639b89ad719909afaa46","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"57e4cd5da492b94a5bc5639b89ad719909afaa46","size":2794,"noattachment":false,"key":"/init-file-loader/-/init-file-loader-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/init-file-loader/download/init-file-loader-0.1.0.tgz"},"directories":{},"publish_time":1430298694511,"_cnpm_publish_time":1430298694511,"_hasShrinkwrap":false}},"readme":"# init-file-loader [![NPM version](https://badge.fury.io/js/init-file-loader.svg)](http://badge.fury.io/js/init-file-loader)\n\n> Loader for Template, for loading files onto a custom view collection inside a vinyl plugin.\n\n## Install with [npm](npmjs.org)\n\n```bash\nnpm i init-file-loader --save\n```\n\n## Usage\n\n**Register the loader**\n\nRegister `init-file-loader` as a custom loader:\n\n```js\napp.loader('file', [require('init-file-loader')]);\n```\n\n`app` is used as a placeholder for [Verb], [Assemble], [Generate](https://github.com/generate/generate), or any application based on [Template].\n\n**Use the loader**\n\nThis is used in the built-in `init` plugin in Assemble and Verb.\n\n* The `.getTask()` method is used to get the name (`id`) of the currently running task.\n* The `.create()` method uses the `id` to create a custom template type for that task\n* The `file` loader is assigned to the template type. This basically means that the `file` loader will be called on every file that is loaded.\n\n**Example usage in a plugin**\n\n```js\nvar through = require('through2');\n\nmodule.exports = function myPlugin() {\n  var app = this;\n  var id = this.getTask();\n\n  // create a template type for vinyl files and assign the loader\n  if (!app.hasOwnProperty(id)) {\n    // `id` is something like `task_foo`\n    app.create(id, ['file']);\n  }\n\n  return through.obj(function (file, enc, cb) {\n\n    // Here, we call the method we created above, which would \n    // be something like `app.task_foo()`. This is the same exact \n    // thing that `assemble.page()` does, or `verb.docs()`.\n    // \n    // Instead of `pages` or `docs`, the loader we're using will \n    // convert the vinyl file to a template and add it to the \n    // `task_foo` collection.\n    app[id](file);\n    cb();\n  }, function (cb) {\n    app.pushToStream(id, this);\n    cb();\n  });\n};\n```\n\n## Related projects\n\n* [assemble](http://assemble.io): Static site generator for Grunt.js, Yeoman and Node.js. Used by Zurb Foundation, Zurb Ink, H5BP/Effeckt,… [more](http://assemble.io)\n* [middleware-utils](https://github.com/jonschlinkert/middleware-utils): Utils for Template middleware.\n* [template](https://github.com/jonschlinkert/template): Render templates using any engine. Supports, layouts, pages, partials and custom template types. Use template… [more](https://github.com/jonschlinkert/template)\n* [template-utils](https://github.com/jonschlinkert/template-utils): Utils for [Template](https://github.com/jonschlinkert/template).\n* [verb](https://github.com/assemble/verb): Documentation generator for GitHub projects. Extremely powerful, easy to use, can generate anything from API… [more](https://github.com/assemble/verb)\n\n## Running tests\n\nInstall dev dependencies:\n\n```bash\nnpm i -d && npm test\n```\n\n## Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/init-file-loader/issues)\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 (c) 2015 Jon Schlinkert\nReleased under the MIT license.\n\n***\n\n_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on April 29, 2015._\n\n<!-- reflinks generated by verb-reflinks plugin -->\n\n[assemble]: http://assemble.io\n[template]: https://github.com/jonschlinkert/template\n[verb]: https://github.com/assemble/verb","_attachments":{},"homepage":"https://github.com/jonschlinkert/init-file-loader","bugs":{"url":"https://github.com/jonschlinkert/init-file-loader/issues"},"license":{"type":"MIT","url":"https://github.com/jonschlinkert/init-file-loader/blob/master/LICENSE"}}