Skip to content

moyus/laravel-mix-nunjucks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Nov 20, 2022
fa1d2d6 · Nov 20, 2022

History

44 Commits
Nov 20, 2022
Oct 14, 2022
Apr 27, 2022
Feb 10, 2020
Feb 28, 2021
Nov 20, 2022
Feb 11, 2020
Apr 27, 2022

Repository files navigation

laravel-mix-nunjucks

npm

Laravel Mix extension to compile Nunjucks templates with markdown and front-matter support

Install

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

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
  • envOptions - These are options provided for nunjucks Environment. More info here.
  • manageEnv - Hook for managing environment before compilation. Useful for adding custom filters, globals, etc

For more info about nunjucks, check https://mozilla.github.io/nunjucks/api.html