Skip to content

Commit

Permalink
Docs updates—adds a documentation page for each individual template e…
Browse files Browse the repository at this point in the history
…ngine.
  • Loading branch information
zachleat committed Mar 26, 2018
1 parent ff4125c commit 017de50
Show file tree
Hide file tree
Showing 12 changed files with 341 additions and 56 deletions.
87 changes: 32 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# eleventy 🕚
# eleventy 🕚 v0.3.0

A simpler static site generator. An alternative to Jekyll. Written in JavaScript. Transforms a directory of templates (of varying types) into HTML.

Works with:

* HTML (`.html`)
* Markdown (`.md`) (using [`markdown-it`](https://github.com/markdown-it/markdown-it))
* [Liquid](https://www.npmjs.com/package/liquidjs) (`.liquid`) (used by Jekyll)
* [Nunjucks](https://mozilla.github.io/nunjucks/) (`.njk`)
* [Handlebars](https://github.com/wycats/handlebars.js) (`.hbs`)
* [Mustache](https://github.com/janl/mustache.js/) (`.mustache`)
* [EJS](https://www.npmjs.com/package/ejs) (`.ejs`)
* [Haml](https://github.com/tj/haml.js) (`.haml`)
* [Pug](https://github.com/pugjs/pug) (formerly Jade, `.pug`)
* JavaScript Template Literals (`.jstl`) (\`strings with backticks\`)
* [HTML (`.html`)](/docs/engines.html.md)
* [Markdown (`.md`)](/docs/engines/markdown.md)
* [Liquid (`.liquid`)](/docs/engines/liquid.md) (Jekyll’s default)
* [Nunjucks (`.njk`)](/docs/engines/nunjucks.md)
* [Handlebars (`.hbs`)](/docs/engines/handlebars.md)
* [Mustache (`.mustache`)](/docs/engines/mustache.md)
* [EJS (`.ejs`)](/docs/engines/ejs.md)
* [Haml (`.haml`)](/docs/engines/haml.md)
* [Pug (`.pug`)](/docs/engines/pug.md) (formerly known as Jade)
* [JavaScript Template Literals (`.jstl`)](/docs/engines/jstl.md) (\`strings with backticks\`)

**New**: Use the above links to learn more about each type and how they work in Eleventy.

## Table of Contents

Expand All @@ -22,9 +24,8 @@ Works with:
* [Using Data](#using-data-optional)
* [Ignore Files](#ignore-files-optional)
* [Configuration](#configuration-optional)
* [Template Engine Features](#template-engine-features)
* [Tests](#tests)
* [Competitors](#competitors)
* [Tests](#tests)
* [Roadmap](#major-roadmapped-features)

### Read More at:
Expand Down Expand Up @@ -123,7 +124,7 @@ DEBUG=Eleventy* eleventy

This will tell you exactly what directories Eleventy is using for data, includes, input, and output. It’ll tell you what search globs it uses to find your templates and what templates it finds. If you’re having trouble, enable this.

_(New in Eleventy `v0.2.16`)_ Works great with `--dryrun` if you want to run Eleventy but not actually write any files.
_(New in Eleventy `v0.3.0`)_ Works great with `--dryrun` if you want to run Eleventy but not actually write any files.

Read more at the [`debug` package documentation](https://www.npmjs.com/package/debug).

Expand Down Expand Up @@ -177,10 +178,6 @@ Note that `{{ title }}` above outputs the `title` data value (this can come from
* `collections`: Lists of all of your content, grouped by tags. [Read more about Collections](docs/collections.md)
* `page`: Has information about the current page. Currently holds: `{ url: "/current/page/url.html", date: [JS Date Object for current page] }`. Useful for finding the current page in a collection. [Read more about Collections](docs/collections.md) (look at _Example: Navigation Links with an `active` class added for on the current page_).

## Ignore files (optional)

Add an `.eleventyignore` file to the _root of your input directory_ for a new line-separated list of files (or globs) that will not be processed. Paths listed in your project’s `.gitignore` file are automatically ignored.

## Configuration (optional)

Add an `.eleventy.js` file to root directory of your project to override these configuration options with your own preferences. Example:
Expand Down Expand Up @@ -213,7 +210,7 @@ module.exports = {
If you expose your config as a function instead of an object, we’ll pass in a `config` argument that you can use!

```
module.exports = function(config) {
module.exports = function(eleventyConfig) {
return {
dir: {
input: "views"
Expand All @@ -222,7 +219,7 @@ module.exports = function(config) {
};
```

This allows you to customize your template engines by using the Config helper methods.
This allows you further customization options using the provided Config helper methods.

#### Add Tags/Filters to Template Engines

Expand All @@ -236,56 +233,36 @@ Read more about [Collections: Advanced Custom Filtering and Sorting](docs/collec

Read more about [Plugins](docs/plugins.md).

## Template Engine Features

Here are the features tested with each template engine that use external files and thus are subject to setup and scaffolding.

| Engine | Feature | Syntax |
| ---------- | -------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| ejs | ✅ Include (Preprocessor Directive) | `<% include /user/show %>` looks for `_includes/user/show.ejs` |
| ejs | ✅ Include (pass in Data) | `<%- include('/user/show', {user: 'Ava'}) %>` looks for `_includes/user/show.ejs` |
| Liquid | ✅ Include | `{% include 'user' %}` looks for `_includes/user.liquid` |
| Liquid | ✅ Include (pass in Data) | `{% include 'user' with 'Ava' %}` |
| Liquid | ✅ Include (pass in Data) | `{% include 'user', user1: 'Ava', user2: 'Bill' %}` |
| Liquid | ✅ Set `liquidjs` library options with Configuration API _(New in Eleventy `v0.2.15`)_ | `eleventyConfig.setLiquidOptions({"dynamicPartials": true});` |
| Liquid | ✅ Custom Filters | `{{ name \| upper }}` (see `config.addLiquidFilter` documentation) |
| Liquid | ✅ Custom Tags | `{% upper name %}` (see `config.addLiquidTag` documentation) |
| Mustache | ✅ Partials | `{{> user}}` looks for `_includes/user.mustache` |
| Handlebars | ✅ Partials | `{{> user}}` looks for `_includes/user.hbs` |
| Handlebars | ✅ Helpers | See `handlebarsHelpers` configuration option. |
| HAML | ❌ but 🔜 Filters | |
| Pug | ✅ Includes (Absolute) | `include /includedvar.pug` looks in `_includes/includedvar.pug` |
| Pug | ✅ Includes (Relative) _(New in Eleventy `v0.2.15`)_ | `include includedvar.pug` looks in `_includes/includedvar.pug` |
| Pug | ✅ Extends (Absolute) | `extends /layout.pug` looks in `_includes/layout.pug` |
| Pug | ✅ Extends (Relative) _(New in Eleventy `v0.2.15`)_ | `extends layout.pug` looks in `_includes/layout.pug` |
| Pug | ✅ Set render/compile options with Configuration API _(New in Eleventy `v0.2.15`)_ | `eleventyConfig.setPugOptions({"debug": true});` |
| Nunjucks | ✅ Includes | `{% include 'included.njk' %}` looks in `_includes/included.njk` |
| Nunjucks | ✅ Extends | `{% extends 'base.njk' %}` looks in `_includes/base.njk` |
| Nunjucks | ✅ Imports | `{% import 'macros.njk' %}` looks in `_includes/macros.njk` |
| Nunjucks | ✅ Filters | Read more about [Filters](docs/filters.md) |

## Tests
## Ignore files (optional)

* Build Status: [![Build Status](https://travis-ci.org/11ty/eleventy.svg?branch=master)](https://travis-ci.org/11ty/eleventy)
* [Code Coverage Statistics](docs/coverage.md)
Add an `.eleventyignore` file to the _root of your input directory_ for a new line-separated list of files (or globs) that will not be processed. Paths listed in your project’s `.gitignore` file are automatically ignored.

```
npm run test
```
_Exception: node_modules will be ignored automatically if a `.gitignore` does not exist._

## Competitors

This project aims to directly compete with all other Static Site Generators. Try out our competition:

* [Jekyll](https://jekyllrb.com/) (Ruby)
* [Hugo](https://gohugo.io/) (Go)
* [Hexo](https://hexo.io/) (JavaScript)
* [Gatsby](https://www.gatsbyjs.org/) (JavaScript using React)
* [Nuxt](https://www.staticgen.com/nuxt) (JavaScript using Vue)
* _More at [staticgen.com](https://www.staticgen.com/)_

## Tests

* Build Status: [![Build Status](https://travis-ci.org/11ty/eleventy.svg?branch=master)](https://travis-ci.org/11ty/eleventy)
* [Code Coverage Statistics](docs/coverage.md)

```
npm run test
```

## Major Roadmapped Features

* [x] Pagination
* [x] Tagging of content
* [x] Plugin system
* [ ] Extensibility with system-wide content mapping **IN PROGRESS**
* [ ] Extensibility with system-wide content mapping
* [ ] Components system for development reusability
2 changes: 1 addition & 1 deletion docs/engines.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
_(New in Eleventy `v0.2.14`)_ There are a couple of different ways you can tell Eleventy how you want to process a file:

1. The file extension (importantly, this is also used to find files to process).
2. [Configuration options](../README.md#configuration-optional)
2. [Configuration options](/README.md#configuration-optional)

* `markdownTemplateEngine`: The default global template engine to pre-process markdown files. Use `false` to avoid pre-processing and only transform markdown.
* `htmlTemplateEngine`: The default global template engine to pre-process HTML files. Use `false` to avoid pre-processing and passthrough copy the content (HTML is not transformed, so technically this could be any plaintext).
Expand Down
38 changes: 38 additions & 0 deletions docs/engines/ejs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# EJS

| Eleventy Short Name | File Extension | NPM Package |
| ------------------- | -------------- | ------------------------------------------ |
| `ejs` | `.ejs` | [`ejs`](https://www.npmjs.com/package/ejs) |

You can override a `.ejs` file’s template engine. Read more at [Changing a Template’s Rendering Engine](/docs/engines.md).

## Set your own Library instance

_New in Eleventy `v0.3.0`:_ As an escape mechanism for advanced usage, pass in your own instance of the EJS library using the Configuration API.

```js
module.exports = function(eleventyConfig) {
let ejs = require("ejs");
eleventyConfig.setLibrary("ejs", ejs);
};
```

## Compile/Render Options

_New in Eleventy `v0.3.0`:_ See “Options” on the [EJS home page](https://ejs.co/).

```
module.exports = function(eleventyConfig) {
eleventyConfig.setEjsOptions({
// use <? ?> instead of <% %>
delimiter: "?"
});
};
```

## Supported Features

| Feature | Syntax |
| ----------------------------------- | --------------------------------------------------------------------------------- |
| ✅ Include (Preprocessor Directive) | `<% include /user/show %>` looks for `_includes/user/show.ejs` |
| ✅ Include (pass in Data) | `<%- include('/user/show', {user: 'Ava'}) %>` looks for `_includes/user/show.ejs` |
27 changes: 27 additions & 0 deletions docs/engines/haml.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# HAML

| Eleventy Short Name | File Extension | NPM Package |
| ------------------- | -------------- | -------------- |
| `haml` | `.haml` | [`haml.js`](c) |

You can override a `.haml` file’s template engine. Read more at [Changing a Template’s Rendering Engine](/docs/engines.md).

## Set your own Library instance

_New in Eleventy `v0.3.0`:_ As an escape mechanism for advanced usage, pass in your own instance of the HAML library using the Configuration API.

```js
module.exports = function(eleventyConfig) {
let haml = require("hamljs");
eleventyConfig.setLibrary("haml", haml);
};
```

## Supported Features

| Feature | Syntax |
| -------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| <!-- | _TODO_ Filters | |
| _TODO_ [Eleventy Universal Filters](/docs/filters.md#built-in-universal-filters) | `:filterName some text` (see `eleventyConfig.addFilter` documentation) |

-->
26 changes: 26 additions & 0 deletions docs/engines/handlebars.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Handlebars

| Eleventy Short Name | File Extension | NPM Package |
| ------------------- | -------------- | ---------------------------------------------------------- |
| `hbs` | `.hbs` | [`handlebars.js`](https://github.com/wycats/handlebars.js) |

You can override a `.hbs` file’s template engine. Read more at [Changing a Template’s Rendering Engine](/docs/engines.md).

## Set your own Library instance

_New in Eleventy `v0.3.0`:_ As an escape mechanism for advanced usage, pass in your own instance of the Handlebars library using the Configuration API.

```js
module.exports = function(eleventyConfig) {
let handlebars = require("handlebars");
eleventyConfig.setLibrary("hbs", handlebars);
};
```

## Supported Features

| Feature | Syntax |
| ---------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| ✅ Partials | `{{> user}}` looks for `_includes/user.hbs` |
| ✅ Helpers | `{{ helperName myObject }}` Handlebars calls them Helpers, but Eleventy calls them filters. Read more about [filters](/docs/filters.md) |
|[Eleventy Universal Filters](/docs/filters.md#built-in-universal-filters) | `{{ filterName myObject }}` (see `eleventyConfig.addFilter` documentation) |
9 changes: 9 additions & 0 deletions docs/engines/html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# HTML

| Eleventy Short Name | File Extension | NPM Package |
| ------------------- | -------------- | ----------- |
| `html` | `.html` | N/A |

HTML files can be optionally pre-processed with an additional template engine. This can be configured on a per-template basis or globally. Read more at [Changing a Template’s Rendering Engine](/docs/engines.md).

⚠️ Careful with this template type when using the same `--input` and `--output` directory (this is not the default). Please read the [Common Pitfalls documentation](/docs/pitfalls.md#same-input-output).
11 changes: 11 additions & 0 deletions docs/engines/jstl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# JavaScript Template Literals

| Eleventy Short Name | File Extension | NPM Package |
| ------------------- | -------------- | ----------- |
| `jstl` | `.jstl` | N/A |

You can override a `.jstl` file’s template engine. Read more at [Changing a Template’s Rendering Engine](/docs/engines.md).

Read more about [JavaScript Template Literals on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals).

Tagged templates are not yet supported.
55 changes: 55 additions & 0 deletions docs/engines/liquid.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Liquid

| Eleventy Short Name | File Extension | NPM Package |
| ------------------- | -------------- | ---------------------------------------------------- |
| `liquid` | `.liquid` | [`liquidjs`](https://www.npmjs.com/package/liquidjs) |

You can override a `.liquid` file’s template engine. Read more at [Changing a Template’s Rendering Engine](/docs/engines.md).

## Library Options

### Defaults

Rather than constantly fixing outdated documentation, [find `getLiquidOptions` in `Liquid.js`](https://github.com/11ty/eleventy/blob/master/src/Engines/Liquid.js). These options are different than the [default `liquidjs` options](https://github.com/harttle/liquidjs#options).

### Use your own options

_New in Eleventy `v0.2.15`:_ It’s recommended to use the Configuration API to set override the default options above.

```js
module.exports = function(eleventyConfig) {
eleventyConfig.setLiquidOptions({
dynamicPartials: true
});
};
```

#### Set your own Library instance

_New in Eleventy `v0.3.0`:_ As an escape mechanism for advanced usage, pass in your own instance of the Liquid library using the Configuration API. See [all `liquidjs` options](https://github.com/harttle/liquidjs#options).

⚠️ Not compatible with `setLiquidOptions` above—this method will ignore any configuration set there.

```js
module.exports = function(eleventyConfig) {
let liquidJs = require("liquidjs");
let options = {
extname: ".liquid",
dynamicPartials: true,
root: ["_includes"]
};

eleventyConfig.setLibrary("liquid", liquidJs(options));
};
```

## Supported Features

| Feature | Syntax |
| ---------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| ✅ Include | `{% include 'user' %}` looks for `_includes/user.liquid` |
| ✅ Include (pass in Data) | `{% include 'user' with 'Ava' %}` |
| ✅ Include (pass in Data) | `{% include 'user', user1: 'Ava', user2: 'Bill' %}` |
| ✅ Custom Filters | `{{ name \| upper }}` (see `eleventyConfig.addLiquidFilter` documentation) |
|[Eleventy Universal Filters](/docs/filters.md#built-in-universal-filters) | `{% name \| filterName %}` (see `eleventyConfig.addFilter` documentation) |
| ✅ Custom Tags | `{% upper name %}` (see `eleventyConfig.addLiquidTag` documentation) |
Loading

0 comments on commit 017de50

Please sign in to comment.