Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

assemble

Package Overview
Dependencies
Maintainers
1
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assemble

Get the rocks out of your socks. Assemble helps you **quickly launch static web projects** by emphasizing a strong separation of concerns between structure, style, content and configuration.

  • 0.3.21
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.1K
increased by7.67%
Maintainers
1
Weekly downloads
 
Created
Source

Assemble v0.3.21 Build Status

Get the rocks out of your socks. Assemble helps you quickly launch static web projects by emphasizing a strong separation of concerns between structure, style, content and configuration.

This project just launched so expect frequent changes. And if you find this project interesting please consider starring it to receive updates.

Getting Help

Assemble has many more features implemented than what we've documented thus far, so check back frequently for udates. If you have any questions or have any trouble getting Assemble to work, please feel free to create an Issue, we'd love to help.

Please visit the wiki

Table of Contents

Quick start

This plugin requires Grunt ~0.4.1

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

with npm
npm install assemble --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('assemble');
without npm

The following quick start alternatives are available:

Compile Templates and Run Tests

Before you get started you must first install the required local dependencies:

$ npm install

When completed, you'll be able to run the various grunt commands provided:

build - grunt assemble

Runs the assemble task to rebuild the project.

test - grunt test

Runs jshint on JavaScripts and mocha unit tests on your templates.

watch - grunt watch

This is a convenience method for watching your templates and automatically re-building them whenever you save. Requires the grunt-contrib-watch Grunt plugin.

Should you encounter problems with installing dependencies or running the grunt commands, be sure to first uninstall any previous versions (global and local) you may have installed, and then rerun npm install.

The "assemble" task

In your project's Gruntfile, add a section named assemble to the data object passed into grunt.initConfig().

grunt.initConfig({
  assemble: {
    options: {
      // Task-specific options go here.
    },
    your_target: {
      // Target-specific file lists and/or options go here.
    }
  }
});
grunt.loadNpmTasks('assemble');

grunt.registerTask('default', [
  'jshint', 
  'assemble'
]);

Task targets, files and options may be specified according to the grunt Configuring tasks guide.

Options

See the Options section on the Wiki for more information.

assets

Type: String Default: false

TODO...

Used by the {{assets}} template to resolve the relative path to the dest assets folder from the dest file.

Example:

assemble: {
  options: {
    assets: 'dist/assets'
  },
  ...
}

Example usage:

<link href="{{assets}}/css/styles.css" rel="stylesheet">

Resulting in:

<link href="dist/assets/css/styles.css" rel="stylesheet">
data

Type: String Default: src/data

Data from specified JSON and/or YAML files gets passed through the data object to the options on the assemble task, then to the context in your templates. The data object is also useful for adding configuration data. Note that Handlebars.js is the only supported template engine at this time. If you would like to see another engine added to Assemble, please make a feature request (or pull request).

Example:

assemble: {
  options: {
    data: ['src/data/*.{json,yml,yaml}', 'config/global.json', 'styles/bootstrap.json']
  },
  ...
}

Data: widget.json

{
  "name": "Square Widget",
  "modifier": "widget-square"
}

Template: widget.hbs

<div class="widget {{ widget.modifier }}">{{ widget.name }}</div>

Compiled result after running grunt assemble:

<div class="widget widget-square">Square Widget</div>

Also see: YAML front matter todo...

layout

Type: String Default: undefined

Path to the layout to be used.

assemble: {
  options: {
    layout: 'src/layouts/default.hbs'
  },
  files: {
    'docs': ['src/files/*.hbs']
  }
}
partials

Type: String Default: undefined

Accepts minimatch patterns to define the Handlebars partials files, or paths to the directories of files to be used.

assemble: {
  options: {
    partials: ['src/partials/*.hbs', 'src/snippets/*.hbs']
  },
  files: {
    'docs': ['src/files/*.hbs']
  }
}
engine

Type: String Default: handlebars

The engine to use for processing client-side templates. Assemble ships Handlebars as the default template engine, if you are interested in using a different engine visit the documentation to see an up-to-date list of template engines.

Pull requests are welcome for additional template engines. Since we're still working to update the docs, you many also contact @doowb for more information or create an [Issue][assemble-issues].

helpers

Type: String Default: undefined

Path defined to a directory of custom helpers to use with the specified template engine. Assemble currently includes more than 75 built-in Handlebars helpers, since Handlebars is the default engine for Assemble.

assemble: {
  options: {
    helpers: 'your/custom/helpers'
  },
  ...
}
ext

Type: String Default: .html

Specify the file extension for destination files. Example:

assemble: {

  // Build sitemap from JSON and templates
  sitemap: {
    options: {
      ext: '.xml'
    },
    files: {
      '.': ['path/to/sitemap.tmpl']
    }
  },

  // Build README from YAML and templates
  readme: {
    options: {
      ext: '.md'
    },
    files: {
      '.': ['path/to/readme.tmpl']
    }
  }
}
flatten

Type: Boolean Default: false

Remove anything after (and including) the first "." in the destination path, then append this value.

YAML options

Assemble makes the following options available from js-yaml. See js-yaml for more information.

filename

Type: String Default: null

String to be used as a file path in error/warning messages.

strict

Type: Boolean Default: false

Makes the loader to throw errors instead of warnings.

schema

Type: String Default: DEFAULT_SCHEMA

Specifies a schema to use.

Custom Options

Contexts

A common use case for custom options is to add contexts for development and production environments:

assemble {
  myProject: {
    options: {
      development: true,
      production: false
    },
    files: {
      'dest': ['src/templates*.hbs']
    }
  }
}

In your templates just wrap sections with these contexts to include or exclude content based on current working environment.

{{#development}}
<script src="script.js"></script>
{{/development}}
{{#production}}
<script src="script.min.js"></script>
{{/production}}

Usage Examples

Markdown

Wouldn't it be awesome if you could just use markdown however you wanted, wherever you needed it?

Assemble gives you the flexibility to:

  • Write entire documents in markdown, and later compile them to HTML
  • Keep sections of documents in externalized markdown files, so they can be imported into other documents
  • Embed or write "inline" markdown on-the-fly inside HTML documents

Read more about markdown features and options in the markdown documentation.

"Include" extenal content

Use the markdown expression, {{md}}, to enable importing of external markdown content.

Example #1: using full path

{{md ../path/to/content.md}}

Example #2: using variables Or use a variable instead of setting the path directly inside the template. For example you can add the content variable to a YAML header:

---
page:
  title: Home
content: ../path/to/content.md
---

then use it like this:

{{md content}}
Write "inline" markdown

The {{#markdown}}{{/markdown}} block expression allows markdown to be written "inline" with any HTML and handlebars content.

Example:

{{#markdown}}
# Inline Markdown is awesome

> this is markdown content

  * useful for simple content
  * great for blog posts
  * easier on the eyes than angle brackets
  * even links look prettier

### Pretty links
[Visit Assemble](https://github.com/assemble/assemble)

### Even Prettier links
Embed handlebars templates to make them even prettier.
{{#page.links}}
[{{text}}]({{href}})
{{/page.links}}

{{/markdown}}

Task defaults

Task targets, files and options may be specified according to the grunt Configuring tasks guide.

Build templates
assemble: {
  templates: {
    files: {
      'index.html': ['index.hbs']
    }
  }
}
Build multiple specified files individually

You can specify multiple destination: [source] items in files.

assemble: {
  gh_pages: {
    files: {
      'docs': ['getting-started.hbs'],
      '.':    ['index.hbs']
    }
  }
}
Build directory of files

Grunt supports filename expansion (also know as globbing) via the built-in [node-glob][node-glob] and [minimatch][minimatch] libraries. So Templates may be used in filepaths or glob patterns.

assemble: {
  project: {
    files: {
      '.': ['templates/*.hbs']
    }
  }
}

Example Projects

Browse the examples folder to get a better idea of what Assemble can do. To build the examples run grunt examples.

Build Bootstrap's Grid with JSON or YAML

This example shows how to use JSON and handlebars templates to manipulate Bootstrap's grid system. We only have to define the grid one time using templates, then we can updated the grid columns, rows, and even content from a JSON or YAML file.

Screenshot The finished result of the example project looks like this:

grid


This is what our handlebars grid looks like. No really, this is the code for the entire grid!:

{{#grid.container}}
  <div class="container">
  {{#rows}}
    <div class="row">
      {{#columns}}
        <div class="span{{width}}"> {{md content}} </div>
      {{/columns}}
    </div>
  {{/rows}}
  </div>
{{/grid.container}}

And then we use an external data file, either grid.yml or grid.json, to configure the grid and provide the content.

YAML version This is the data for our grid, written in YAML (grid.yml):

---
container:
  rows:
  - columns:
    - width: 4
      heading: Overview
      content: <%= content %>/overview.md
    - width: 4
      heading: Getting Started
      content: <%= content %>/getting-started.md
    - width: 4
      heading: Basics
      content: <%= content %>/basics.md
  - columns:
    - width: 6
      heading: Templates
      content: <%= content %>/templates.md
    - width: 6
      heading: Advanced
      content: <%= content %>/advanced.md
...

JSON version

And the same configuration writtin in JSON (grid.json) instead:

{
  "container": {
    "rows": [
      {
        "columns": [
          {
            "width": 4,
            "heading": "Overview",
            "content": "<%= content %>/overview.md"
          },
          {
            "width": 4,
            "heading": "Getting Started",
            "content": "<%= content %>/getting-started.md"
          },
          {
            "width": 4,
            "heading": "Basics",
            "content": "<%= content %>/basics.md"
          }
        ]
      },
      {
        "columns": [
          {
            "width": 6,
            "heading": "Templates",
            "content": "<%= content %>/templates.md"
          },
          {
            "width": 6,
            "heading": "Advanced",
            "content": "<%= content %>/advanced.md"
          }
        ]
      }
    ]
  }
}

If you're satisfied with the default src and dest paths in the assemble, simply run grunt assemble to compile the grid to static HTML. Or run grunt watch to continuously watch files and automatically re-build when changes occur.

Contributing

Want to help make assemble even better? All constructive feedback and contributions are welcome, so please consider contributing! We can always use help creating, tests, documentation or resolving Issues, but if you have other ideas for how you can help, Brian and I would love to hear them!

https://github.com/assemble/assemble/issues

Authors

Jon Schlinkert

Brian Woodward

Copyright 2013 Assemble

MIT License

Release History

  • 2013-03-18 v0.3.14 new relative helper for resolving relative paths
  • 2013-03-16 v0.3.13 new dashify and formatPhone helpers
  • then-til-now v0.1.0-v0.3.0 Leaned how to commit too many times while working on README.
  • Stardate 45047.2 v0.1.0 Visited the uninhabited El-Adrel system. Returned home. Started assemble.

Roadmap

(Big plans in the works)

Authored by assemble

This file was generated using Grunt and assemble on Fri Mar 22 2013 08:27:25.

Keywords

FAQs

Package last updated on 22 Mar 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc