├── test
├── fixtures
│ ├── stuff
│ │ ├── run.dmc
│ │ └── test.dmc
│ ├── test.coffee
│ ├── test
│ │ └── run.jade
│ ├── copy
│ │ └── example.txt
│ ├── pages
│ │ ├── about.hbs
│ │ ├── home.hbs
│ │ └── blog.hbs
│ ├── includes
│ │ ├── info.hbs
│ │ ├── footer.hbs
│ │ ├── header.hbs
│ │ └── post.hbs
│ └── layouts
│ │ ├── default.hbs
│ │ ├── base.hbs
│ │ └── post.hbs
└── test.js
├── .gitattributes
├── .jshintrc
├── .verbrc.md
├── .gitignore
├── LICENSE-MIT
├── package.json
├── README.md
└── index.js
/test/fixtures/stuff/run.dmc:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/fixtures/stuff/test.dmc:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/fixtures/test.coffee:
--------------------------------------------------------------------------------
1 | this is a test
--------------------------------------------------------------------------------
/test/fixtures/test/run.jade:
--------------------------------------------------------------------------------
1 | test template
--------------------------------------------------------------------------------
/test/fixtures/copy/example.txt:
--------------------------------------------------------------------------------
1 | this is a test
--------------------------------------------------------------------------------
/test/fixtures/pages/about.hbs:
--------------------------------------------------------------------------------
1 | ---
2 | title: About Page
3 | ---
4 | {{> info }}
--------------------------------------------------------------------------------
/test/fixtures/pages/home.hbs:
--------------------------------------------------------------------------------
1 | ---
2 | title: Home Page
3 | ---
4 | {{> info }}
--------------------------------------------------------------------------------
/test/fixtures/includes/info.hbs:
--------------------------------------------------------------------------------
1 |
(From info.hbs) - Title: {{site.title}} - {{title}}
--------------------------------------------------------------------------------
/test/fixtures/layouts/default.hbs:
--------------------------------------------------------------------------------
1 | ---
2 | layout: base
3 | ---
4 | {{> header }}
5 | {{ body }}
6 | {{> footer }}
--------------------------------------------------------------------------------
/test/fixtures/includes/footer.hbs:
--------------------------------------------------------------------------------
1 | ---
2 | message: Message from the footer
3 | ---
4 | Footer {{message}}
--------------------------------------------------------------------------------
/test/fixtures/includes/header.hbs:
--------------------------------------------------------------------------------
1 | ---
2 | message: Message from the header
3 | ---
4 | Header {{message}}
--------------------------------------------------------------------------------
/test/fixtures/layouts/base.hbs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{site.title}}
6 |
7 |
8 | {{body}}
9 |
10 |
--------------------------------------------------------------------------------
/test/fixtures/pages/blog.hbs:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | show-full: false
4 | title: Blog Page
5 | ---
6 | {{> info }}
7 |
8 | {{#each posts}}
9 | {{> post this}}
10 | {{/each}}
11 |
--------------------------------------------------------------------------------
/test/fixtures/includes/post.hbs:
--------------------------------------------------------------------------------
1 | {{author}}
2 | {{timestamp}}
3 | {{#if ../show-full}}
4 |
5 | {{content}}
6 |
7 | {{else}}
8 |
9 | {{summary}}
10 |
11 | {{/if}}
12 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Enforce Unix newlines
2 | *.* text eol=lf
3 | *.css text eol=lf
4 | *.html text eol=lf
5 | *.js text eol=lf
6 | *.json text eol=lf
7 | *.less text eol=lf
8 | *.md text eol=lf
9 | *.yml text eol=lf
10 |
11 | *.jpg binary
12 | *.gif binary
13 | *.png binary
14 | *.jpeg binary
--------------------------------------------------------------------------------
/test/fixtures/layouts/post.hbs:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | ---
4 |
5 | {{body}}
6 |
7 |
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "esnext": true,
3 | "boss": true,
4 | "curly": true,
5 | "eqeqeq": true,
6 | "eqnull": true,
7 | "immed": true,
8 | "latedef": true,
9 | "newcap": true,
10 | "noarg": true,
11 | "node": true,
12 | "sub": true,
13 | "undef": true,
14 | "unused": true,
15 | "globals": {
16 | "define": true,
17 | "before": true,
18 | "after": true,
19 | "describe": true,
20 | "it": true
21 | }
22 | }
--------------------------------------------------------------------------------
/.verbrc.md:
--------------------------------------------------------------------------------
1 | ---
2 | tags: ['verb-tag-jscomments']
3 | ---
4 |
5 | # {%= name %} {%= badge("fury") %}
6 |
7 | > {%= description %}
8 |
9 | ## Install
10 | {%= include("install") %}
11 |
12 | ## Buffer
13 | {%= jscomments("index.js") %}
14 |
15 |
16 | ## Author
17 | {%= include("author") %}
18 |
19 | ## License
20 | {%= copyright() %}
21 | {%= license() %}
22 |
23 | ***
24 |
25 | {%= include("footer") %}
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Numerous always-ignore extensions
2 | *.csv
3 | *.dat
4 | *.diff
5 | *.err
6 | *.gz
7 | *.log
8 | *.orig
9 | *.out
10 | *.pid
11 | *.rej
12 | *.seed
13 | *.swo
14 | *.swp
15 | *.vi
16 | *.yo-rc.json
17 | *.zip
18 | *~
19 | .ruby-version
20 | lib-cov
21 |
22 | # OS or Editor folders
23 | *.esproj
24 | *.sublime-project
25 | *.sublime-workspace
26 | ._*
27 | .cache
28 | .DS_Store
29 | .idea
30 | .project
31 | .settings
32 | .tmproj
33 | nbproject
34 | Thumbs.db
35 |
36 | # Komodo
37 | *.komodoproject
38 | .komodotools
39 |
40 | # grunt-html-validation
41 | validation-status.json
42 | validation-report.json
43 |
44 | # Vendor packages
45 | node_modules
46 | bower_components
47 | vendor
48 |
49 | # General folders and files to ignore
50 | _gh_pages
51 | tmp
52 | temp
53 | TODO.md
--------------------------------------------------------------------------------
/LICENSE-MIT:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014 , contributors.
2 |
3 | Permission is hereby granted, free of charge, to any person
4 | obtaining a copy of this software and associated documentation
5 | files (the "Software"), to deal in the Software without
6 | restriction, including without limitation the rights to use,
7 | copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the
9 | Software is furnished to do so, subject to the following
10 | conditions:
11 |
12 | The above copyright notice and this permission notice shall be
13 | included in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/test/test.js:
--------------------------------------------------------------------------------
1 | var should = require('should');
2 | var join = require('path').join;
3 | require('mocha');
4 |
5 | var assemble = require('assemble');
6 | var buffer = require('../')(assemble);
7 |
8 |
9 | describe('assemble-middleware-buffer', function(){
10 | it('should return a stream', function(done) {
11 | var stream = buffer();
12 | should.exist(stream);
13 | should.exist(stream.on);
14 | done();
15 | });
16 | it('should buffer files to an array named `posts` on the assemble context', function(done) {
17 | var stream = assemble.src(join(__dirname, "./fixtures/pages/*.hbs")).pipe(buffer());
18 | stream.on('error', done);
19 | stream.on('data', function () {});
20 | stream.on('end', function () {
21 | should.exist(assemble.context['posts']);
22 | done();
23 | });
24 | });
25 | it('should buffer files to an array named `test-files` on the assemble context', function(done) {
26 | var stream = assemble.src(join(__dirname, "./fixtures/pages/*.hbs")).pipe(buffer({type: 'test-files'}));
27 | stream.on('error', done);
28 | stream.on('data', function () {});
29 | stream.on('end', function () {
30 | should.exist(assemble.context['test-files']);
31 | done();
32 | });
33 | });
34 | });
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "assemble-middleware-buffer",
3 | "description": "Buffer files into a specified array on the Assemble context.",
4 | "version": "0.1.0",
5 | "homepage": "https://github.com/assemble/assemble-middleware-buffer",
6 | "author": {
7 | "name": "Brian Woodward",
8 | "url": "https://github.com/doowb"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git://github.com/assemble/assemble-middleware-buffer.git"
13 | },
14 | "bugs": {
15 | "url": "https://github.com/assemble/assemble-middleware-buffer/issues"
16 | },
17 | "licenses": [
18 | {
19 | "type": "MIT",
20 | "url": "https://github.com/assemble/assemble-middleware-buffer/blob/master/LICENSE-MIT"
21 | }
22 | ],
23 | "keywords": [
24 | "docs",
25 | "documentation",
26 | "generate",
27 | "generator",
28 | "markdown",
29 | "templates",
30 | "verb"
31 | ],
32 | "main": "index.js",
33 | "engines": {
34 | "node": ">=0.10.0"
35 | },
36 | "scripts": {
37 | "test": "mocha -R spec"
38 | },
39 | "devDependencies": {
40 | "verb": "~0.2.6",
41 | "chai": "~1.9.1",
42 | "mocha": "*",
43 | "verb-tag-jscomments": "^0.1.4"
44 | },
45 | "dependencies": {
46 | "through2": "^0.5.1",
47 | "xtend": "^3.0.0"
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # assemble-middleware-buffer [](http://badge.fury.io/js/assemble-middleware-buffer)
3 |
4 | > Buffer files into a specified array on the Assemble context.
5 |
6 | ## Install
7 | Install with [npm](npmjs.org):
8 |
9 | ```bash
10 | npm i assemble-middleware-buffer --save-dev
11 | ```
12 |
13 | ## Buffer
14 | ### buffer
15 |
16 | Add files to the specified array on Assemble.
17 |
18 | **Usage**
19 |
20 | ```js
21 | var assemble = require('assemble');
22 | var buffer = require('assemble-middleware-buffer')(assemble);
23 | var tap = require('gulp-tap');
24 |
25 | assemble.src('path/to/pages/*.hbs')
26 | .pipe(buffer({type: 'posts'}))
27 | .pipe(tap(function (file) {
28 | console.log('posts', assemble.posts);
29 | });
30 | ```
31 |
32 | * `options` {Object}: object containing options: * {String} `type` name of the array to store the files in.
33 | * `return` {Stream} stream to continue piping.
34 |
35 |
36 | ## Author
37 |
38 | **Brian Woodward**
39 |
40 | + [github/assemble](https://github.com/assemble)
41 | + [twitter/assemble](http://twitter.com/assemble)
42 |
43 | ## License
44 | Copyright (c) 2014 Brian Woodward, contributors.
45 | Released under the MIT license
46 |
47 | ***
48 |
49 | _This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on June 30, 2014._
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * assemble-middleware-buffer
3 | *
4 | * Copyright (c) 2014 Brian Woodward, contributors.
5 | * Licensed under the MIT license.
6 | */
7 |
8 | 'use strict';
9 |
10 | var through = require('through2');
11 | var extend = require('xtend');
12 |
13 | /**
14 | * ## buffer
15 | *
16 | * Add files to the specified array on Assemble.
17 | *
18 | * **Usage**
19 | *
20 | * ```js
21 | * var assemble = require('assemble');
22 | * var buffer = require('assemble-middleware-buffer')(assemble);
23 | * var tap = require('gulp-tap');
24 | *
25 | * assemble.src('path/to/pages/*.hbs')
26 | * .pipe(buffer({type: 'posts'}))
27 | * .pipe(tap(function (file) {
28 | * console.log('posts', assemble.posts);
29 | * });
30 | * ```
31 | *
32 | * @param {Object} `options` object containing options:
33 | * * {String} `type` name of the array to store the files in.
34 | * @return {Stream} stream to continue piping.
35 | */
36 |
37 | module.exports = function (assemble) {
38 |
39 | return function buffer (options) {
40 | options = extend({type: 'posts'}, options);
41 | var cache = [];
42 |
43 | var throughput = function throughput (file, enc, callback) {
44 | cache.push(file);
45 | callback();
46 | };
47 | var flush = function flush (callback) {
48 | assemble.set(options.type, cache);
49 | cache.forEach(this.push.bind(this));
50 | callback();
51 | };
52 |
53 | return through.obj(throughput, flush);
54 | };
55 |
56 | };
--------------------------------------------------------------------------------