Neutral Point Measurement


    1.2.1 • Public • Published

    Fabricator Assemble

    Build Status npm version

    The assembly engine behind Fabricator. Not associated with Assemble.

    Turn this:

    title: Document Name
    name: World
    <h1>{{home.greeting}}, {{name}}!</h1>
    {{> button}}

    into this:

    <!doctype html>
    <html lang="en">
        <title>Document Name</title>
        <h1>Hello, World!</h1>
        <a href="#" class="button">Click me!</a>


    The task returns a promise, so it can be used in an async task runner, like Gulp:

    var assemble = require('fabricator-assemble');
    var gulp = require('gulp');
    gulp.task('assemble', function () {
    	return assemble(options);

    The task accepts options, but assumes this directory structure:

    └── src
    	├── data
    	│   └── *.{json,yml}
    	├── docs
    	│   └── *.md
    	├── materials
    	│   └── components
    	│       └── *.html
    	└── views
    	    ├── *.html
    	    └── layouts
    	        └── default.html


    Default options:

    	layout: 'default',
    	layouts: 'src/views/layouts/*',
    	layoutIncludes: 'src/views/layouts/includes/*',
    	views: ['src/views/**/*', '!src/views/+(layouts)/**'],
    	materials: 'src/materials/**/*',
    	data: 'src/data/**/*.{json,yml}',
    	docs: 'src/docs/**/*.md',
    	keys: {
    		materials: 'materials',
    		views: 'views',
    		docs: 'docs'
    	helpers: {},
    	logErrors: false,
    	onError: function(error) {},
    	dest: 'dist'


    Type: String
    Default: default

    Name of the default layout template.


    Type: String or Array
    Default: src/views/layouts/*

    Files to use as layout templates.


    Type: String or Array
    Default: src/views/layouts/includes/*

    Files to use as layout includes.


    Type: String or Array
    Default: ['src/views/**/*', '!src/views/+(layouts)/**']

    Pages to pass through the assembler to be templated. Fabricator pages are stored at the root level views and user-defined views can be stored in subdirectories.


    Type: String or Array
    Default: src/materials/**/*

    Files to use a partials/helpers. These are the materials that make up your toolkit. by default, Fabricator comes with "components" and "structures", but you can define your own taxonomy.

    Type: String or Array
    Default: src/data/**/*.{json,yml}

    JSON or YAML files to use as data for views.

    Type: String or Array
    Default: src/docs/**/*.md

    Markdown files containing toolkit-wide documentation


    Type: Objects
    Default: materials/views/docs

    Object keywords for accessing "materials", "views", and "docs" in a view templating context. Fabricator uses some specific terms like "materials" to describe what are really "partials" in Handelbars. This option give you the flexibility to define your own terms for materials, views, and docs.

    For example:

    	keys: {
    		materials: 'patterns'
    <!-- formerly `{{#each materials}}` -->
    {{#each patterns}}
    	{{#each items}}

    Note: this will also change the built-in {{material <foo>}} helper to use the singular form of whatever is defined for the materials key. e.g. materialKey: 'patterns' -> {{pattern <foo>}}. If you set a new key for materials, you will also need to update the f-item-content.html include to use the new helper name.


    Type: Object
    Default: {}

    User-defined helpers. E.g.:

    helpers: {
    	markdown: require('helper-markdown'),
    	foo: function () {
    		return 'bar';


    Type: Boolean
    Default: false

    Whether or not to log errors to console. If set to false, the app will exit on error.


    Type: Function
    Default: null

    Error handler function. Receives an error object param.


    Type: String
    Default: dist

    Destination of compiled views (where files are saved to)



    • Layouts: wrapper templates
    • Views: individual pages
    • Materials: partial views; registered as "partials" and "helpers" in Handlebars
    • Data: Data piped in as template context
    • Docs: Markdown files containing documentation.


    Layouts are wrappers for pages. You can define as many layouts as you want by creating .html files in your layouts folder.

    Example layout:

    <!doctype html>
    <html lang="en">
        {% body %}

    Page content is inserted in the {% body %} placeholder.

    Context can be passed from a page to the layout via front matter.

    The layout a page uses is also defined in front matter:

    layout: custom-layout
    title: My Custom Layout

    This would use custom-layout.html.

    When no layout property is defined, the page uses the default layout.


    Views are unique pages templated using Handlebars. These are both Fabricator pages and user-created pages (i.e. example templates)

    View example:

    title: Document Name
    name: World
    <h1>{{home.greeting}}, {{name}}!</h1>
    {{> button}}

    This outputs a page that uses the default layout (since no layout was defined).

    The front matter block at the top provides context to both the layout and the page itself.

    Context is also piped in from data files (see below). In this example, {{home.greeting}} refers to the greeting property in home.json.

    Fabricator pages are typically stored at the root level of the views directory and user-created views (e.g. "templates", "pages", "interfaces") should be stored in subdirectories.


    Materials are partial templates; think of them as the materials used to build pages.

    They are accessed as a "partial" using the > syntax in Handlebars:

    {{> material-name}}

    Any file in the glob defined in options.materials is turned into a partial/helper and can be accessed as such. For example, assume the components contains materials:

    └── components
        ├── button.html
        └── form-toggle.html

    The content within these files can be accessed as such:

    {{> button}}
    {{> form-toggle}}


    You can manually order materials by prefixing the file name with numbers:


    This defines the order in which materials will appear in the side menu or other places the materials.items context is used.

    Note: The number prefixes are ignored when registering partials, so you'll still be able to access them using the material name per usual. e.g.:

    {{> foo}}
    {{> bar}}
    {{> qux}}

    The numbers are also ignored in the .name property. The materials above would list as:



    Data is defined as JSON or YAML.

    The data folder can contain several .json or .yml files:

    └── data
        ├── home.json
        └── contact.yml


      "greeting": "Hello"

    The data within each file can be accessed using dot notation:



    Docs are just a generic way to capture toolkit documenation that's not specific to a material. This could be something like JavaScript architecture, accessibility guidelines, etc.

    Docs are written in markdown and are stored in src/docs by default.



    npm i @datacamp/fabricator-assemble

    DownloadsWeekly Downloads






    Last publish


    • bereketmebrahtu
    • marbdq-dc
    • ben.brooker
    • wadiator
    • mzetea
    • jang_dc
    • woutceudc
    • jboguski-dc
    • yunchen44
    • thomasbeckx
    • frederikvg
    • peter.buschenreiter
    • nhlongnguyen
    • bobby.clare
    • nathandatacamp
    • cdalby
    • luigi-dintrono-dc
    • eoliveiradc
    • berndschrooten
    • _bogdan_floris_
    • denathoxhadc
    • sajtempler-dc
    • bartlens
    • kyryl_kurylchenko
    • filipsch
    • meehirpateldatacamp
    • malex-datacamp
    • gillvdw
    • slava-dc
    • ztsorojev
    • smidge
    • alanhughesdatacamp
    • catufuzgu
    • felipeneuhauss
    • joachimzeelmaekers
    • garyalway
    • carmenchapa
    • jdmunro
    • hettiemcc
    • close-d-dev
    • herve-eerebout
    • ddmkr
    • dandenney
    • entropitor
    • ewaldbervoets
    • cnydw
    • rikbw
    • nicolasdesmedt
    • lazzystep
    • abordanpeter
    • aarondc
    • hermansje
    • nunorafaelrocha
    • thomascorthouts
    • nickvdyck
    • timsangster
    • tuur
    • lipsumar
    • caterina
    • datacamp-org
    • chrisramakers
    • irakli_dc
    • ppetermann
    • springerigor
    • iryna059
    • louiejakebell
    • blurbyte
    • kogitoja
    • larisa-datacamp
    • rahien
    • samwooler
    • alexravs
    • forvalho
    • stijnj
    • deanterweduwe
    • bruno.datacamp
    • marcin-data
    • julienbenaouda