1 | <p align="center">
|
2 |
|
3 | <a href="https://github.com/assemble/assemble">
|
4 | <img height="250" width="250" src="https://raw.githubusercontent.com/assemble/assemble/master/docs/logo.png">
|
5 | </a>
|
6 | </p>
|
7 |
|
8 | # assemble
|
9 |
|
10 | [![NPM version](https://img.shields.io/npm/v/assemble.svg?style=flat)](https://www.npmjs.com/package/assemble) [![NPM monthly downloads](https://img.shields.io/npm/dm/assemble.svg?style=flat)](https://npmjs.org/package/assemble) [![Build Status](https://img.shields.io/travis/assemble/assemble.svg?style=flat)](https://travis-ci.org/assemble/assemble) [![Gitter](https://badges.gitter.im/join_chat.svg)](https://gitter.im/assemble/assemble)
|
11 |
|
12 | Looking for the grunt plugin? Please visit [grunt-assemble](https://github.com/assemble/grunt-assemble).
|
13 |
|
14 | _(Note that the current website assemble.io, is for [grunt-assemble](https://github.com/assemble/grunt-assemble). Thanks for your patience while we work on updating the site with documentation for the latest assemble)_.
|
15 |
|
16 | ## Overview
|
17 |
|
18 | _(Click the following sections to expand them)_
|
19 |
|
20 | <details>
|
21 | <summary>Table of contents</summary>
|
22 | - [Quickstart](#quickstart)
|
23 | * [Install assemble](#install-assemble)
|
24 | * [Create a new project](#create-a-new-project)
|
25 | * [Run assemble](#run-assemble)
|
26 | - [Getting started](#getting-started)
|
27 | * [Rendering templates](#rendering-templates)
|
28 | * [Running tasks](#running-tasks)
|
29 | - [CLI](#cli)
|
30 | * [Running tasks](#running-tasks-1)
|
31 | * [Specifying options](#specifying-options)
|
32 | * [Object expansion](#object-expansion)
|
33 | - [Command line options](#command-line-options)
|
34 | * [cwd](#cwd)
|
35 | * [file](#file)
|
36 | - [API](#api)
|
37 | * [Templates API](#templates-api)
|
38 | + [.create](#create)
|
39 | + [View types](#view-types)
|
40 | + [.engine](#engine)
|
41 | + [.render](#render)
|
42 | * [File System API](#file-system-api)
|
43 | + [.src](#src)
|
44 | + [.dest](#dest)
|
45 | + [.copy](#copy)
|
46 | + [.renderFile](#renderfile)
|
47 | * [Task API](#task-api)
|
48 | + [.task](#task)
|
49 | + [.build](#build)
|
50 | + [.watch](#watch)
|
51 | - [Plugins](#plugins)
|
52 | * [Discovering plugins](#discovering-plugins)
|
53 | * [Authoring plugins](#authoring-plugins)
|
54 | - [Learning](#learning)
|
55 | * [Help](#help)
|
56 | * [More information](#more-information)
|
57 | * [FAQ](#faq)
|
58 | - [About](#about)
|
59 | * [Community](#community)
|
60 | * [Related projects](#related-projects)
|
61 | * [Similar projects](#similar-projects)
|
62 | * [Release history](#release-history)
|
63 | * [Contributing](#contributing)
|
64 | * [Authors](#authors)
|
65 | * [License](#license)
|
66 |
|
67 | _(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_
|
68 | </details>
|
69 |
|
70 | <details>
|
71 | <summary>What is Assemble?</summary>
|
72 | Assemble is a command line tool and developer framework for rapid prototyping, static site generation, and [much more](#what-can-i-do-with-assemble).
|
73 | </details>
|
74 |
|
75 | <details>
|
76 | <summary>Who uses assemble?</summary>
|
77 | Assemble is used by thousands of developers and teams in more than 170 countries! Here are a few examples of sites built with assemble:
|
78 |
|
79 | * [Airbus Group](http://www.airbusgroup.com/int/en.html)
|
80 | * [Diebold](http://www.diebold.com/)
|
81 | * [Transformicons](http://www.transformicons.com/)
|
82 | * [Barrel](https://www.barrelny.com/)
|
83 | * [yesware](https://www.yesware.com/)
|
84 | * [Amaze](https://www.amaze.com/)
|
85 | * [sennheiser](http://sennheiser-d1.com/)
|
86 | * [perf.rocks](http://perf.rocks/)
|
87 | * [Milano JS](http://milanojs.com/)
|
88 | * [AKQA](http://www.akqa.com/)
|
89 | * [huxtaburger](http://www.huxtaburger.com.au/)
|
90 | * [Typeplate](http://typeplate.com/)
|
91 | * [Angular Basics](http://www.angularjsbook.com/)
|
92 |
|
93 | Is your website, blog or project built with assemble? Please [let us know about it](../../issues/300)!
|
94 | </details>
|
95 |
|
96 | <details>
|
97 | <summary>Why should I use assemble?</summary>
|
98 |
|
99 | * Expressive, functional API (the API is also stable)
|
100 | * You can use assemble with any web framework or CSS/HTML toolkit
|
101 | * Assemble can build static sites or hybrid static/dynamic sites
|
102 | * Streams support, you can run any [gulp](http://gulpjs.com) plugin
|
103 | * [Powerful features](#features) for rapid web development, including a robust API for rendering templates with any node.js template engine.
|
104 | * Assemble can use any [base](https://github.com/node-base/base) plugin
|
105 | * Assemble can do anything Jekyll does, but with more flexibility and control
|
106 | * Like gulp, assemble can also run **any** other static site generator as a plugin, which means you can do anything and everything all other node.js static site generators can do, and much more.
|
107 | </details>
|
108 |
|
109 | <details>
|
110 | <summary>What can I do with Assemble?</summary>
|
111 |
|
112 | * Rapid prototyping
|
113 | * Static site generation (more powerful alternative to jekyll)
|
114 | * Landing pages
|
115 | * A/B testing
|
116 | * [blogs](examples/blog)
|
117 | * Styleguides
|
118 | * Themes
|
119 | * UI components
|
120 | * [Project scaffolder](examples/generator) ([generate](https://github.com/generate/generate) is also built on assemble)
|
121 | * [build tool](examples/build-tool)
|
122 | * Documentation ([verb](https://github.com/verbose/verb) is built on assemble)
|
123 | * Generate [boilerplates](examples/boilerplates), [scaffolds](examples/scaffold), and [targets](examples/targets)
|
124 | * E-books ([Angular Basics](http://www.angularjsbook.com/) was built with assemble)
|
125 | * Much more!
|
126 |
|
127 | </details>
|
128 |
|
129 | <details>
|
130 | <summary>Rapid development toolkit</summary>
|
131 | Assemble can be used standalone, but it's even more powerful when used alongside the following libraries:
|
132 |
|
133 | * [generate](https://github.com/generate/generate): scaffold out new projects from the command line
|
134 | * [assemble](https://github.com/assemble/): <= you are here
|
135 | * [verb](https://github.com/verbose/verb): generate documention for your projects
|
136 | * [update](https://github.com/update/update): keep your projects up-to-date
|
137 |
|
138 | </details>
|
139 |
|
140 | <details>
|
141 | <summary>Features</summary>
|
142 | Here are just a few of the features assemble offers:
|
143 |
|
144 | * Intuitive CLI
|
145 | * Full support for [gulp](http://gulpjs.com) and [base](https://github.com/node-base/base) plugins
|
146 | * Assemble templates are [vinyl](https://github.com/gulpjs/vinyl) files
|
147 | * Render templates with any [template engine](#engine), including [nunjucks](https://github.com/assemble/assemble-nunjucks), [handlebars](https://github.com/jonschlinkert/engine-handlebars), [lodash](https://github.com/jonschlinkert/engine-lodash) and any consolidate engine!
|
148 | * Use multiple engines, assemble can detect the one to use based on file extension
|
149 | * [helpers](#helpers): support for sync and async
|
150 | * [Templates collections](#collections)
|
151 | * Pages
|
152 | * Partials/includes
|
153 | * [Layouts](https://github.com/doowb/layouts)
|
154 | * Pagination
|
155 | * [permalinks](https://github.com/assemble/assemble-permalinks)
|
156 | * [middleware](#middleware) can be used to tranform files at any stage in the render cycle
|
157 | * Generate pages from JSON
|
158 | * Much more!
|
159 |
|
160 | </details>
|
161 |
|
162 | ## Quickstart
|
163 |
|
164 | Create a new assemble project in less than 3 minutes!
|
165 |
|
166 | ### Install assemble
|
167 |
|
168 | Install assemble's CLI globally:
|
169 |
|
170 | ```sh
|
171 | $ npm install --global assemble
|
172 | ```
|
173 |
|
174 | This adds the `assemble` command to your system path, allowing it to be run from any directory.
|
175 |
|
176 | ### Create a new project
|
177 |
|
178 | Scaffold out a new assemble project using [generate-assemble][] (a project generator, powered by [generate](https://github.com/generate/generate)).
|
179 |
|
180 | **Install generate-assemble**
|
181 |
|
182 | ```sh
|
183 | $ npm install --global generate generate-assemble
|
184 | ```
|
185 |
|
186 | **Scaffold out a new assemble project**
|
187 |
|
188 | ```sh
|
189 | $ gen assemble
|
190 | ```
|
191 |
|
192 | ### Run assemble
|
193 |
|
194 | Time to build your assemble project!
|
195 |
|
196 | ```sh
|
197 | $ assemble
|
198 | ```
|
199 |
|
200 | This will give you a preview of how assemble works, continue reading for more information and documentation.
|
201 |
|
202 | ## Getting started
|
203 |
|
204 | See the [quickstart](#quickstart) section to learn how to install assemble. After that, you're ready to start rendering!
|
205 |
|
206 | ### Rendering templates
|
207 |
|
208 | Render a template _(the default engine is [handlebars](https://github.com/jonschlinkert/engine-handlebars), but you can use any engine you want)_:
|
209 |
|
210 | ```js
|
211 | var assemble = require('assemble');
|
212 | var app = assemble();
|
213 |
|
214 | // add a "page" nd render it!
|
215 | app.page('home.hbs', {content: 'This is \{{title}}'})
|
216 | .render({title: 'Home!'}, function(err, view) {
|
217 | if (err) throw err;
|
218 | console.log(view.content);
|
219 | //=> 'This is Home!'
|
220 | });
|
221 | ```
|
222 |
|
223 | ### Running tasks
|
224 |
|
225 | Create an `assemblefile.js` and add tasks to run:
|
226 |
|
227 | ```js
|
228 | var assemble = require('assemble');
|
229 | var htmlmin = require('gulp-htmlmin');
|
230 | var app = assemble();
|
231 |
|
232 | app.page('a.hbs', {content: '...'});
|
233 | app.page('b.hbs', {content: '...'});
|
234 | app.page('c.hbs', {content: '...'});
|
235 |
|
236 | app.task('default', function() {
|
237 | return app.toStream('pages') //<= push "pages" collection into stream
|
238 | .pipe(app.renderFile()) //<= render pages with default engine (hbs)
|
239 | .pipe(htmlmin()) //<= gulp plugin for minifying html
|
240 | .pipe(app.dest('site')); //<= write files to the "./site" directory
|
241 | });
|
242 |
|
243 | // expose your instance of assemble to assemble's CLI
|
244 | module.exports = app;
|
245 | ```
|
246 |
|
247 | ## CLI
|
248 |
|
249 | Run assemble from the command line.
|
250 |
|
251 | ```sh
|
252 | $ assemble <tasks> [options]
|
253 | ```
|
254 |
|
255 | ### Running tasks
|
256 |
|
257 | Specify one or more space-separated tasks to run.
|
258 |
|
259 | **Examples**
|
260 |
|
261 | Run task `foo`
|
262 |
|
263 | ```sh
|
264 | $ assemble foo
|
265 | ```
|
266 |
|
267 | Run tasks `foo` and `bar`
|
268 |
|
269 | ```sh
|
270 | $ assemble foo bar
|
271 | ```
|
272 |
|
273 | ### Specifying options
|
274 |
|
275 | Non-task options are prefixed with `--`.
|
276 |
|
277 | **Examples**
|
278 |
|
279 | Set the `--cwd` to run an assemblefile.js in a different directory:
|
280 |
|
281 | ```sh
|
282 | $ assemble --cwd=docs
|
283 | ```
|
284 |
|
285 | Emit views as they're loaded and log them to `stderr`:
|
286 |
|
287 | ```sh
|
288 | $ assemble --emit=view
|
289 | ```
|
290 |
|
291 | See more [command line options](#command line options)
|
292 |
|
293 | ### Object expansion
|
294 |
|
295 | Object-paths may be specified using dot-notation for **either the key or value** in a command line argument.
|
296 |
|
297 | Additionally, assemble uses [expand-object](https://github.com/jonschlinkert/expand-object) (and some custom parsing) to make it easier to pass non-trivial options and commands via command line. So all of the following formats are possible.
|
298 |
|
299 | **Examples**
|
300 |
|
301 | Boolean values:
|
302 |
|
303 | ```sh
|
304 | $ assemble --foo
|
305 | # { foo: true }
|
306 | ```
|
307 |
|
308 | Key-value pairs:
|
309 |
|
310 | ```sh
|
311 | $ assemble --foo=bar
|
312 | # { foo: 'bar' }
|
313 | ```
|
314 |
|
315 | Nested booleans:
|
316 |
|
317 | ```sh
|
318 | $ assemble --option=foo
|
319 | # {options: { foo: true }}
|
320 | ```
|
321 |
|
322 | Nested key-value pairs:
|
323 |
|
324 | ```sh
|
325 | $ assemble --option=foo:bar
|
326 | # {options: { foo: 'bar' }}
|
327 | ```
|
328 |
|
329 | Deeply nested key-value pairs:
|
330 |
|
331 | ```sh
|
332 | $ assemble --option=foo.bar.baz:qux
|
333 | # {options: foo: { bar: { baz: 'qux' }}}}
|
334 | ```
|
335 |
|
336 | Or on the left-side of the `=`:
|
337 |
|
338 | ```sh
|
339 | $ assemble --option.foo.bar.baz=qux
|
340 | # {options: foo: { bar: { baz: 'qux' }}}}
|
341 | ```
|
342 |
|
343 | ## Command line options
|
344 |
|
345 | ### cwd
|
346 |
|
347 | Change the `cwd` for the `assemblefile.js` to run, optionally specifying any tasks to run:
|
348 |
|
349 | ```sh
|
350 | $ assemble <tasks> --cwd [directory]
|
351 | ```
|
352 |
|
353 | **Example**
|
354 |
|
355 | To run the `scaffolds` example in the `examples/` directory, you would enter:
|
356 |
|
357 | ```sh
|
358 | $ assemble --cwd examples/scaffolds
|
359 | ```
|
360 |
|
361 | If successful, in the command line, you should see something like this:
|
362 |
|
363 | <img width="527" alt="screen shot 2016-01-09 at 1 35 52 pm" src="https://cloud.githubusercontent.com/assets/383994/12217685/0a14294e-b6d6-11e5-9e06-dc4738f0e53a.png">
|
364 |
|
365 | ### file
|
366 |
|
367 | Specify the name of the config file for assemble's CLI to run, the default is `assemblefile.js`.
|
368 |
|
369 | **Example**
|
370 |
|
371 | ```sh
|
372 | $ assemble --file assemblefile.dev.js
|
373 | ```
|
374 |
|
375 | ## API
|
376 |
|
377 | ### [Assemble](index.js#L24)
|
378 |
|
379 | Create an `assemble` app. This is the main function exported by the assemble module.
|
380 |
|
381 | **Params**
|
382 |
|
383 | * `options` **{Object}**: Optionally pass default options to use.
|
384 |
|
385 | **Example**
|
386 |
|
387 | ```js
|
388 | var assemble = require('assemble');
|
389 | var app = assemble();
|
390 | ```
|
391 |
|
392 | ### Templates API
|
393 |
|
394 | Assemble exposes the entire API from the [templates](https://github.com/jonschlinkert/templates) library for working with templates and template collections. The API is much more extensive than what is documented here, see [templates](https://github.com/jonschlinkert/templates) for more documentation.
|
395 |
|
396 | **Templates and Views**
|
397 |
|
398 | In the following documentation, the terms "template" and "view" both refer to _aspects_ of the same thing. Here's what they mean:
|
399 |
|
400 | * `template`: an actual template string
|
401 | * `view`: a object with a `content` property that contains the template string. Since views are instances of [vinyl](https://github.com/gulpjs/vinyl), you can think of a view as a "vinyl file for templates".
|
402 |
|
403 | #### .create
|
404 |
|
405 | Create a template collection for caching [views](https://github.com/cpsubrian/node-views):
|
406 |
|
407 | ```js
|
408 | app.create('includes', {viewType: 'partial'});
|
409 | ```
|
410 |
|
411 | **Options**
|
412 |
|
413 | * `cwd` **{String}**: the base directory to use when loading templates onto the collection from a glob
|
414 |
|
415 | * `viewType`: **{String|Array}**: One or more [view types](#view-types) to associate with the collection
|
416 |
|
417 | **Add views**
|
418 |
|
419 | Add a view to the collection:
|
420 |
|
421 | ```js
|
422 | app.include('foo.md', {contents: new Buffer('this is contents')});
|
423 | ```
|
424 |
|
425 | Add multiple views:
|
426 |
|
427 | ```js
|
428 | app.includes({
|
429 | path: 'foo.md', contents: new Buffer('this is contents'),
|
430 | path: 'bar.md', contents: new Buffer('this is contents'),
|
431 | path: 'baz.md', contents: new Buffer('this is contents')
|
432 | });
|
433 |
|
434 | // or pass a glob (optionally override `cwd` defined on `.create`)
|
435 | app.includes('*.{md,hbs}', {cwd: 'templates/includes'});
|
436 | ```
|
437 |
|
438 | #### View types
|
439 |
|
440 | View types are defined on a collection to determine how a templates in the collection will be handled throughout the [render cycle][].
|
441 |
|
442 | **Available types**
|
443 |
|
444 | Assemble supports three view types:
|
445 |
|
446 | * `partial`: Views with this type are can be used as "partials" (or "partial views"), which can be injected into other views. Useful for components, document fragments, or other snippets of reusable code or content. These views are passed to rendering engines to be used as partials, or variables on the context if partials are not directly supported.
|
447 | * `layout`: allows views to "wrap" other views (of any type, including other layouts or partials) with common code or content.
|
448 | * `renderable`: Views that have a one-to-one relationship with rendered files that will eventually be visible to a user or visitor to a website. For example: pages or blog posts. The `renderable` view type is automatically set if no other view types are set.
|
449 |
|
450 | **Defining view types**
|
451 |
|
452 | You can define view types when a collection is created:
|
453 |
|
454 | ```js
|
455 | app.create('snippet', {viewType: 'partial'});
|
456 | ```
|
457 |
|
458 | Or directly on the collection options:
|
459 |
|
460 | ```js
|
461 | app.create('snippet');
|
462 | app.snippets.option('viewType', ['partial']); // string or array
|
463 | ```
|
464 |
|
465 | #### .engine
|
466 |
|
467 | Register template engine for rendering views with the given `ext`:
|
468 |
|
469 | ```js
|
470 | app.engine(ext, fn);
|
471 | ```
|
472 |
|
473 | **Params**
|
474 |
|
475 | * `ext` **{String}**: The file extension of files to render with the engine
|
476 | * `fn` **{Function}**: Async function that follows [consolidate](https://github.com/visionmedia/consolidate.js) engine conventions, and takes three arguments: `str`, `locals` and `callback`.
|
477 |
|
478 | **Example**
|
479 |
|
480 | ```js
|
481 | // this engine is already registered in assemble
|
482 | app.engine('hbs', require('engine-handlebars'));
|
483 |
|
484 | // create a custom engine
|
485 | app.engine('txt', function(str, locals, cb) {
|
486 | // render `str` with `locals`
|
487 | cb(null, str);
|
488 | });
|
489 | ```
|
490 |
|
491 | You can tell assemble to use the same engine for all file extensions by setting a value on `options.engine`.
|
492 |
|
493 | **Example**
|
494 |
|
495 | ```js
|
496 | // use engine `hbs` for rendering all files
|
497 | app.option('engine', 'hbs');
|
498 | ```
|
499 |
|
500 | Or, if you're using [.renderFile](#renderFile), you can force a specific engine to be used by passing the engine name.
|
501 |
|
502 | **Example**
|
503 |
|
504 | Use the `hbs` engine to render all templates:
|
505 |
|
506 | ```js
|
507 | app.src('templates/*.*')
|
508 | .pipe(app.renderFile('hbs'))
|
509 | ```
|
510 |
|
511 | #### .render
|
512 |
|
513 | Render a view with the given `locals` and `callback`.
|
514 |
|
515 | ```js
|
516 | app.render(view, {title: 'Foo'}, function(err, view) {
|
517 | // `view` is an object with a rendered `content` property
|
518 | });
|
519 | ```
|
520 |
|
521 | **Params**
|
522 |
|
523 | * `view` **{Object|String}**: The view to render
|
524 | * `locals` **{Object}**: Locals to pass to template engine for rendering templates in `view`
|
525 | * `callback` **{Function}**
|
526 |
|
527 | ***
|
528 |
|
529 | ### File System API
|
530 |
|
531 | Assemble offers the following low-level methods for working with the file system:
|
532 |
|
533 | * [src](#src)
|
534 | * [symlink](#symlink)
|
535 | * [dest](#dest)
|
536 | * [copy](#copy)
|
537 |
|
538 | Assemble has first-class support for [vinyl-fs](http://github.com/wearefractal/vinyl-fs), so any [gulp](http://gulpjs.com) plugin can be used in your assemble pipeline.
|
539 |
|
540 | #### .src
|
541 |
|
542 | Create a [vinyl](https://github.com/gulpjs/vinyl) stream. Takes glob patterns or filepaths to the source files to read.
|
543 |
|
544 | **Params**
|
545 |
|
546 | * `glob` **{String|Array}**: Glob patterns or file paths to source files.
|
547 | * `options` **{Object}**: Options or locals to merge into the context and/or pass to `src` plugins
|
548 |
|
549 | **Example**
|
550 |
|
551 | ```js
|
552 | app.src('src/*.hbs');
|
553 |
|
554 | // define `src` options
|
555 | app.src('src/*.hbs', { layout: 'default' });
|
556 | ```
|
557 |
|
558 | #### .dest
|
559 |
|
560 | Specify a destination for processed files.
|
561 |
|
562 | **Params**
|
563 |
|
564 | * `dest` **{String|Function}**: File path or rename function.
|
565 | * `options` **{Object}**: Options and locals to pass to `dest` plugins
|
566 |
|
567 | **Example**
|
568 |
|
569 | ```js
|
570 | app.dest('dist/');
|
571 | ```
|
572 |
|
573 | #### .copy
|
574 |
|
575 | Copy files with the given glob `patterns` to the specified `dest`.
|
576 |
|
577 | **Params**
|
578 |
|
579 | * `patterns` **{String|Array}**: Glob patterns of files to copy.
|
580 | * `dest` **{String|Function}**: Desination directory.
|
581 | * `returns` **{Stream}**: Stream, to continue processing if necessary.
|
582 |
|
583 | **Example**
|
584 |
|
585 | ```js
|
586 | app.task('assets', function() {
|
587 | // return, to let assemble know when the task has completed
|
588 | return app.copy('assets/**', 'dist/');
|
589 | });
|
590 | ```
|
591 |
|
592 | #### .renderFile
|
593 |
|
594 | Renders files as they are pushed through the stream.
|
595 |
|
596 | ```js
|
597 | app.src('*.hbs')
|
598 | .pipe(app.renderfile())
|
599 | .pipe(app.dest('foo'));
|
600 | ```
|
601 |
|
602 | Force a specific engine to be used for rendering files:
|
603 |
|
604 | ```js
|
605 | app.engine('txt', function(str, locals, cb) {
|
606 | cb(null, str);
|
607 | });
|
608 |
|
609 | app.src('*.hbs')
|
610 | .pipe(app.renderfile('txt')) //<= use engine `txt`
|
611 | .pipe(app.dest('foo'));
|
612 | ```
|
613 |
|
614 | ***
|
615 |
|
616 | ### Task API
|
617 |
|
618 | Assemble has the following methods for running tasks and controlling workflows:
|
619 |
|
620 | * [task](#task)
|
621 | * [build](#build)
|
622 | * [watch](#watch)
|
623 |
|
624 | #### .task
|
625 |
|
626 | Define a task to be run when the task is called.
|
627 |
|
628 | **Params**
|
629 |
|
630 | * `name` **{String}**: Task name
|
631 | * `fn` **{Function}**: function that is called when the task is run.
|
632 |
|
633 | **Example**
|
634 |
|
635 | ```js
|
636 | app.task('default', function() {
|
637 | app.src('templates/*.hbs')
|
638 | .pipe(app.dest('site/'));
|
639 | });
|
640 | ```
|
641 |
|
642 | #### .build
|
643 |
|
644 | Run one or more tasks.
|
645 |
|
646 | **Params**
|
647 |
|
648 | * `tasks` **{Array|String}**: Task name or array of task names.
|
649 | * `cb` **{Function}**: callback function that exposes `err`
|
650 |
|
651 | **Example**
|
652 |
|
653 | ```js
|
654 | app.build(['foo', 'bar'], function(err) {
|
655 | if (err) throw err;
|
656 | console.log('done!');
|
657 | });
|
658 | ```
|
659 |
|
660 | #### .watch
|
661 |
|
662 | Watch files, run one or more tasks when a watched file changes.
|
663 |
|
664 | **Params**
|
665 |
|
666 | * `glob` **{String|Array}**: Filepaths or glob patterns.
|
667 | * `tasks` **{Array}**: Task(s) to watch.
|
668 |
|
669 | **Example**
|
670 |
|
671 | ```js
|
672 | app.task('watch', function() {
|
673 | app.watch('docs/*.md', ['docs']);
|
674 | });
|
675 | ```
|
676 |
|
677 | ## Plugins
|
678 |
|
679 | ### Discovering plugins
|
680 |
|
681 | Plugins from any applications built on [base](https://github.com/node-base/base) should work with Assemble and can be used in your `assemblefile.js`:
|
682 |
|
683 | * [base](https://www.npmjs.com/browse/keyword/baseplugin): find base plugins on npm using the `baseplugin` keyword
|
684 | * [assemble](https://www.npmjs.com/browse/keyword/assembleplugin): find assemble plugins on npm using the `assembleplugin` keyword
|
685 | * [generate](https://www.npmjs.com/browse/keyword/generateplugin): find generate plugins on npm using the `generateplugin` keyword
|
686 | * [templates](https://www.npmjs.com/browse/keyword/templatesplugin): find templates plugins on npm using the `templatesplugin` keyword
|
687 | * [update][update-plugin]: find update plugins on npm using the `updateplugin` keyword
|
688 | * [verb](https://www.npmjs.com/browse/keyword/verbplugin): find verb plugins on npm using the `verbplugin` keyword
|
689 |
|
690 | ### Authoring plugins
|
691 |
|
692 | Visit the [plugin documentation](docs/plugins.md) guide to learn how to use, author and publish plugins.
|
693 |
|
694 | ## Learning
|
695 |
|
696 | ### Help
|
697 |
|
698 | **Get in touch!**
|
699 |
|
700 | Have questions, suggestions, or want to discuss assemble? Join the conversation on [gitter](http://gitter.im/assemble/assemble) or give us a shout on [twitter](https://twitter.com/assemblejs). The assemble team and community are always happy to help!
|
701 |
|
702 | ### More information
|
703 |
|
704 | * [Documentation](docs)
|
705 | * [API documentation](docs/api)
|
706 | * [Generators maintained by the core team](https://github.com/generate)
|
707 |
|
708 | ### FAQ
|
709 |
|
710 | **Website is outdated and being refactored!**
|
711 |
|
712 | Assemble's website, assemble.io, only has information related to [gulp-assemble](http://assemble.io). We're working hard to update the site with information about the latest release.
|
713 |
|
714 | In the meantime, you might find the [WIP docs](docs/src/content) useful. The [unit tests](test/) are also great examples!
|
715 |
|
716 | **Is the assemble website up-to-date?**
|
717 |
|
718 | No, as mentioned above, it's completely out-of-date. If you're using [grunt-assemble](https://github.com/assemble/grunt-assemble), some of the documentation at assemble.io might still be useful. If you're using assemble v0.6.0 and higher, the documentation is probably wrong in almost every way.
|
719 |
|
720 | We're actively (daily) working on a refactor and it's a very high priority.
|
721 |
|
722 | **What's the difference between [assemble-core](https://github.com/assemble/assemble-core) and assemble?**
|
723 |
|
724 | Assemble adds a CLI, a few built-in view collections: `pages`, `layouts`, and `partials`, middleware for parsing front-matter, and a few other basic defaults that we've found many users expect. If you'd prefer different defaults, [assemble-core](https://github.com/assemble/assemble-core) is a great starting point.
|
725 |
|
726 | If you want something that handles templates, rendering, engines, helpers, collections, etc. but you don't need to run tasks or work with the file system, then consider using [templates](https://github.com/jonschlinkert/templates) instead of assemble-core.
|
727 |
|
728 | **I use gulp, why is it recommended to use assemble directly, instead of running assemble with gulp?**
|
729 |
|
730 | You can run gulp plugins with assemble, but it won't always work the other way around. This is because, as a build system, assemble does things that gulp doesn't do, like handle middleware.
|
731 |
|
732 | For example, assemble's `.src` and `.dest` methods have built-in `.onStream`, `.preWrite`, and `.postWrite` middleware handlers. If you still wish to use gulp and your build cycle includes middleware that requires these handlers, you can use the [assemble-handle](https://github.com/assemble/assemble-handle) plugin with gulp to ensure that the handlers are still called as needed.
|
733 |
|
734 | This is a long way of saying, you can find ways to make gulp work, but you would just be adding an extra dependency to your project to do things that assemble already does.
|
735 |
|
736 | **What is the relationship between gulp and assemble?**
|
737 |
|
738 | Please read our [gulp FAQ](docs/src/subjects/gulp-faq.md) for more information.
|
739 |
|
740 | ## About
|
741 |
|
742 | ### Community
|
743 |
|
744 | Are you using assemble in your project? Have you published an assemble project and want to share your project with the world?
|
745 |
|
746 | Here are some suggestions!
|
747 |
|
748 | * If you get like Assemble and want to tweet about it, please feel free to mention `@assemble` or use the `#assemble` hashtag
|
749 | * Tell us about [your assemble project](https://github.com/assemble/assemble/issues/300)
|
750 | * Show your love by starring [Assemble](https://github.com/assemble/) and `assemble`
|
751 | * Get implementation help on [StackOverflow](http://stackoverflow.com/questions/tagged/assemble) (please use the `assemble` tag in questions)
|
752 | * **Gitter** Discuss Assemble with us on [Gitter](https://gitter.im/assemble/assemble)
|
753 | * If you publish an assemble plugin, thank you! To make your project as discoverable as possible, please add the keyword `assembleplugin` to package.json.
|
754 |
|
755 | **Contributing**
|
756 |
|
757 | Please read our [contributing guide](.github/contributing.md) if you'd like to learn more about contributing to this project.
|
758 |
|
759 | ### Related projects
|
760 |
|
761 | You might also be interested in these projects from [@doowb](https://github.com/doowb) and [@jonschlinkert](https://github.com/jonschlinkert):
|
762 |
|
763 | * [boilerplate](https://www.npmjs.com/package/boilerplate): Tools and conventions for authoring and using declarative configurations for project "boilerplates" that can be… [more](https://github.com/jonschlinkert/boilerplate) | [homepage](https://github.com/jonschlinkert/boilerplate "Tools and conventions for authoring and using declarative configurations for project "boilerplates" that can be consumed by any build system or project scaffolding tool.")
|
764 | * [generate](https://www.npmjs.com/package/generate): Command line tool and developer framework for scaffolding out new GitHub projects. Generate offers the… [more](https://github.com/generate/generate) | [homepage](https://github.com/generate/generate "Command line tool and developer framework for scaffolding out new GitHub projects. Generate offers the robustness and configurability of Yeoman, the expressiveness and simplicity of Slush, and more powerful flow control and composability than either.")
|
765 | * [scaffold](https://www.npmjs.com/package/scaffold): Conventions and API for creating declarative configuration objects for project scaffolds - similar in format… [more](https://github.com/jonschlinkert/scaffold) | [homepage](https://github.com/jonschlinkert/scaffold "Conventions and API for creating declarative configuration objects for project scaffolds - similar in format to a grunt task, but more portable, generic and can be used by any build system or generator - even gulp.")
|
766 | * [update](https://www.npmjs.com/package/update): Be scalable! Update is a new, open source developer framework and CLI for automating updates… [more](https://github.com/update/update) | [homepage](https://github.com/update/update "Be scalable! Update is a new, open source developer framework and CLI for automating updates of any kind in code projects.")
|
767 | * [verb](https://www.npmjs.com/package/verb): Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… [more](https://github.com/verbose/verb) | [homepage](https://github.com/verbose/verb "Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used on hundreds of projects of all sizes to generate everything from API docs to readmes.")
|
768 |
|
769 | ### Similar projects
|
770 |
|
771 | If assemble doesn't do what you need, there are some other great open source projects you might be interested in, created by our friends on GitHub (in alphabetical order):
|
772 |
|
773 | **Static site generators**
|
774 |
|
775 | * [docpad](https://github.com/docpad)
|
776 | * [metalsmith](https://github.com/metalsmith)
|
777 | * [punch](https://github.com/laktek/punch)
|
778 | * [wintersmith](https://github.com/jnordberg/wintersmith)
|
779 |
|
780 | **Blog frameworks**
|
781 |
|
782 | * [hexojs](https://github.com/hexojs)
|
783 | * [ghost](https://github.com/TryGhost/Ghost)
|
784 |
|
785 | ### Release history
|
786 |
|
787 | #### key
|
788 |
|
789 | Changelog entries are classified using the following labels _(from [keep-a-changelog](https://github.com/olivierlacan/keep-a-changelog)_):
|
790 |
|
791 | * `added`: for new features
|
792 | * `changed`: for changes in existing functionality
|
793 | * `deprecated`: for once-stable features removed in upcoming releases
|
794 | * `removed`: for deprecated features removed in this release
|
795 | * `fixed`: for any bug fixes
|
796 |
|
797 | Custom labels used in this changelog:
|
798 |
|
799 | * `dependencies`: bumps dependencies
|
800 | * `housekeeping`: code re-organization, minor edits, or other changes that don't fit in one of the other categories.
|
801 |
|
802 | ### v0.18.0
|
803 |
|
804 | **Dependencies**
|
805 |
|
806 | * bumps [assemble-core](https://github.com/assemble/assemble-core) to 0.27.0
|
807 |
|
808 | ### v0.17.0
|
809 |
|
810 | **Dependencies**
|
811 |
|
812 | * bumps [assemble-core](https://github.com/assemble/assemble-core) to 0.26.0
|
813 |
|
814 | ### v0.16.1
|
815 |
|
816 | * bump dependencies. In particular, there was a bug in [parser-front-matter](https://github.com/jonschlinkert/parser-front-matter) where leading whitespace was removed after extracting front-matter, which caused the first line of indentation to be removed. This has been fixed.
|
817 |
|
818 | ### v0.16.0
|
819 |
|
820 | * **Added**: `.log()` method, which also exposes additional methods, like `.log.info()`, `.log.success()`, etc.
|
821 | * docs were moved to `support/docs`, so that markdown docs can be built to the `docs` directory
|
822 | * docs were updated, new docs added
|
823 | * Moves some private prototype methods to static methods, to allow them to be used without creating an instance
|
824 | * Bumps [assemble-core](https://github.com/assemble/assemble-core) to v0.25.0
|
825 |
|
826 | ### v0.15.0
|
827 |
|
828 | * Bumps [assemble-core](https://github.com/assemble/assemble-core) to v0.24.0 to get the latest versions of [templates](https://github.com/jonschlinkert/templates) and [base-data](https://github.com/node-base/base-data) which removes the `renameKey` option from the `.data` method. Use the `namespace` option instead.
|
829 |
|
830 | ### v0.14.0
|
831 |
|
832 | Bumps [assemble-core](https://github.com/assemble/assemble-core) to v0.22.0 to take advantage of fixes and improvements to lookup methods: `.find` and `getView`. No API changes were made. Please [let us know](../../issues) if regressions occur.
|
833 |
|
834 | * fixes `List` bug that was caused collection helpers to explode
|
835 | * Improvements to lookup functions: `app.getView()` and `app.find()`
|
836 | * Bumps [base](https://github.com/node-base/base) to take advantages of code optimizations.
|
837 |
|
838 | ### v0.13.0
|
839 |
|
840 | * Bumps [assemble-core](https://github.com/assemble/assemble-core) to v0.21.0. Support for the `queue` property was removed on collections. See [assemble-core](https://github.com/assemble/assemble-core) for additional details.
|
841 | * Fixes bug where glob parent was not being used for `file.base`, causing dest directory to be relative to cwd instead of glob parent in some cases.
|
842 | * Some changes were made to context handling that effected one unit test out of ~1,000. although it's unlikely you'll be effected by the change, it warrants a minor bump
|
843 | * Externalizes common [templates](https://github.com/jonschlinkert/templates) tests to base-test-runner, so that assemble plugins and other [base](https://github.com/node-base/base) applications can use the tests
|
844 | * Includes a fix from [assemble-loader](https://github.com/assemble/assemble-loader), where a bug caused `renameKey` to not always be used when defined on collection loader options.
|
845 | * Includes fixes from templates for resolving layouts
|
846 |
|
847 | ### v0.12.0
|
848 |
|
849 | * Bumps [assemble-core](https://github.com/assemble/assemble-core) to v0.18.0, which includes a bump in [templates](https://github.com/jonschlinkert/templates). See the changelog on the templates library for more details.
|
850 |
|
851 | ### v0.11.0
|
852 |
|
853 | * `debug` methods and related code have been removed
|
854 | * Bumps [assemble-core](https://github.com/assemble/assemble-core) to v0.17.0
|
855 |
|
856 | ### v0.10.0
|
857 |
|
858 | * Adds support for using es6 generators with tasks
|
859 | * Bumps [assemble-core](https://github.com/assemble/assemble-core) to v0.15.0
|
860 |
|
861 | ### v0.9.0
|
862 |
|
863 | * Bumps several dependencies. No API changes, this is mostly an optimization release. Be sure to completely remove `node_modules` and reinstall all dependencies to avoid errors such as `isRegistered is not a function`
|
864 |
|
865 | ### v0.8.0
|
866 |
|
867 | * Updates [composer](https://github.com/doowb/composer) to v0.11.0, which removes the `.watch` method in favor of using the [base-watch](https://github.com/node-base/base-watch) plugin.
|
868 | * Changes in [templates](https://github.com/jonschlinkert/templates). Please see v0.11.0 in [templates history](https://github.com/jonschlinkert/templates#history) for more details.
|
869 |
|
870 | ### v0.7.0
|
871 |
|
872 | * Stability improvements and optimizations of the API introduced in v0.6.0.
|
873 |
|
874 | ### v0.6.0
|
875 |
|
876 | * Major refactor. Assemble was completely re-written from the ground-up as a standalone node.js library and is no longer a grunt plugin. Grunt plugin support has been moved to [grunt-assemble](https://github.com/assemble/grunt-assemble). Please see that repo for additional details.
|
877 |
|
878 | ### Contributing
|
879 |
|
880 | Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
881 |
|
882 | Please read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.
|
883 |
|
884 | If Assemble doesn't do what you need, [please let us know](https://github.com/undefined/issues/new)
|
885 |
|
886 | ### Authors
|
887 |
|
888 | **Jon Schlinkert**
|
889 |
|
890 | * [github/jonschlinkert](https://github.com/jonschlinkert)
|
891 | * [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
|
892 |
|
893 | **Brian Woodward**
|
894 |
|
895 | * [github/doowb](https://github.com/doowb)
|
896 | * [twitter/doowb](http://twitter.com/doowb)
|
897 |
|
898 | ### License
|
899 |
|
900 | Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
|
901 | Released under the [MIT license](LICENSE).
|
902 |
|
903 | ***
|
904 |
|
905 | _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.1, on January 17, 2017._ |
\ | No newline at end of file |