Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moyus/laravel-mix-nunjucks
Laravel Mix extension to compile Nunjucks templates
https://github.com/moyus/laravel-mix-nunjucks
laravel-mix markdown nunjucks
Last synced: 2 months ago
JSON representation
Laravel Mix extension to compile Nunjucks templates
- Host: GitHub
- URL: https://github.com/moyus/laravel-mix-nunjucks
- Owner: moyus
- License: mit
- Created: 2020-02-10T08:42:00.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-15T00:17:11.000Z (almost 2 years ago)
- Last Synced: 2024-09-26T20:46:00.950Z (3 months ago)
- Topics: laravel-mix, markdown, nunjucks
- Language: JavaScript
- Size: 655 KB
- Stars: 11
- Watchers: 2
- Forks: 5
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# laravel-mix-nunjucks
![npm](https://img.shields.io/npm/v/laravel-mix-nunjucks?style=flat-square)
Laravel Mix extension to compile Nunjucks templates with markdown and front-matter support
## Install
```bash
npm install laravel-mix-nunjucks --save-dev
```## Features
This extension performs following tasks
- Collect files name not start with `_` or under `_*` directory
- Extract front-matter data and assigns to a `page` variable
- If file is markdown, render markdown first
- Finally, render nunjucks to html## Usage
```javascript
const mix = require('laravel-mix')
require('laravel-mix-nunjucks')mix.njk('resources/views/', 'public/', {
// ext: '.html',
// data: {},
// marked: null,
// envOptions: null,
// manageEnv: (nunjucks) => {},
})
```* `ext` - Extension for compiled templates, pass null or empty string if yo don't want any extension
* `data` - Data passed to template
* `block` - Name of content block in your parent template
* `marked` - Custom options for [marked](http://github.com/chjj/marked)
* `envOptions` - These are options provided for nunjucks Environment. More info [here](https://mozilla.github.io/nunjucks/api.html#configure).
* `manageEnv` - Hook for managing environment before compilation. Useful for adding custom filters, globals, etcFor more info about nunjucks, check [https://mozilla.github.io/nunjucks/api.html](https://mozilla.github.io/nunjucks/api.html)