Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/steverandy/metalsmith-marko

Metalsmith plugin to render files with Marko templates
https://github.com/steverandy/metalsmith-marko

marko metalsmith metalsmith-plugin template

Last synced: 8 days ago
JSON representation

Metalsmith plugin to render files with Marko templates

Awesome Lists containing this project

README

        

# metalsmith-marko

A Metalsmith plugin to render files with [Marko](http://markojs.com/) templates.

It supports rendering source files with templates and layouts. By default it looks for layout files in `layouts` directory. You need to set the `layout` in source file frontmatter section in order to render it in a layout. Optionally, you can set `defaultLayout` in plugin options.

## Installation

```
$ npm install metalsmith-marko
```

## Usage

### Without Options

```javascript
let marko = require("metalsmith-marko")

metalsmith.use(marko())
```

### With Options

```javascript
let marko = require("metalsmith-marko")

metalsmith.use(marko({
layoutsDirectory: "layouts",
defaultLayout: "default.html",
pattern: ["**/*.marko", "**/*.html"],
compilerOptions: {
writeToDisk: false,
preserveWhitespace: true
}
}))
```

### Default Options

```javascript
layoutsDirectory: "layouts",
pattern: ["**/*.marko"],
compilerOptions: {
writeToDisk: false,
preserveWhitespace: true
}
```

### Templates

`layouts/default.html.marko`

```html

${data.title}

$!{data.contents}

```

`pages/index.html.marko`

```html

Heading


${page.title}

```

## License

[MIT License](./LICENSE)