All Projects → SudoCat → Nunjucks Isomorphic Loader

SudoCat / Nunjucks Isomorphic Loader

Licence: mit
Nunjucks loader for webpack, supporting both javascript templating and generating static HTML files through the HtmlWebpackPlugin.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Nunjucks Isomorphic Loader

Inline Style Loader
inline style loader for webpack
Stars: ✭ 16 (-5.88%)
Mutual labels:  webpack, webpack-loader
Vue Template Loader
Vue.js 2.0 template loader for webpack
Stars: ✭ 253 (+1388.24%)
Mutual labels:  webpack, webpack-loader
Angular Router Loader
A Webpack loader that enables string-based module loading with the Angular Router
Stars: ✭ 194 (+1041.18%)
Mutual labels:  webpack, webpack-loader
Workerize Loader
🏗️ Automatically move a module into a Web Worker (Webpack loader)
Stars: ✭ 2,135 (+12458.82%)
Mutual labels:  webpack, webpack-loader
Css Loader
CSS Loader
Stars: ✭ 4,067 (+23823.53%)
Mutual labels:  webpack, webpack-loader
Css Modules Typescript Loader
Webpack loader to create TypeScript declarations for CSS Modules
Stars: ✭ 172 (+911.76%)
Mutual labels:  webpack, webpack-loader
One Loader
Single-file components for React
Stars: ✭ 233 (+1270.59%)
Mutual labels:  webpack, webpack-loader
Bs Loader
📻 Bucklescript loader for Webpack and Jest
Stars: ✭ 146 (+758.82%)
Mutual labels:  webpack, webpack-loader
Sass Loader
Compiles Sass to CSS
Stars: ✭ 3,718 (+21770.59%)
Mutual labels:  webpack, webpack-loader
Markdown Loader
markdown loader for webpack
Stars: ✭ 335 (+1870.59%)
Mutual labels:  webpack, webpack-loader
Pug As Jsx Loader
Stars: ✭ 168 (+888.24%)
Mutual labels:  webpack, webpack-loader
Wasm Loader
✨ WASM webpack loader
Stars: ✭ 604 (+3452.94%)
Mutual labels:  webpack, webpack-loader
Webpack.js.org
Repository for webpack documentation and more!
Stars: ✭ 2,049 (+11952.94%)
Mutual labels:  webpack, webpack-loader
Polymer Webpack Loader
WebPack Loader for Polymer Web Components
Stars: ✭ 192 (+1029.41%)
Mutual labels:  webpack, webpack-loader
File Loader
File Loader
Stars: ✭ 1,846 (+10758.82%)
Mutual labels:  webpack, webpack-loader
String Replace Loader
Replace loader for Webpack
Stars: ✭ 205 (+1105.88%)
Mutual labels:  webpack, webpack-loader
Style Loader
Style Loader
Stars: ✭ 1,572 (+9147.06%)
Mutual labels:  webpack, webpack-loader
Svg Sprite Loader
Webpack loader for creating SVG sprites.
Stars: ✭ 1,822 (+10617.65%)
Mutual labels:  webpack, webpack-loader
Extract Loader
webpack loader to extract HTML and CSS from the bundle
Stars: ✭ 297 (+1647.06%)
Mutual labels:  webpack, webpack-loader
Comlink Loader
Webpack loader to offload modules to Worker threads seamlessly using Comlink.
Stars: ✭ 535 (+3047.06%)
Mutual labels:  webpack, webpack-loader

Nunjucks Isomorphic loader for webpack

Nunjucks loader for webpack, supporting both javascript templating and generating static HTML files through the HtmlWebpackPlugin.

Completely rewritten, now (mostly) error free. Supports context file (.js only) for passing data.

This loader supports the following extensions: .njk, .nunjucks, .html, .tpl, .tmpl

Warning: (Mostly) Unmaintained

Unfortunately, I rarely get much free time to work on this package any more. While I'll always try to answer any questions anyone has, it may take some time and I might not know the correct answer. Luckily the Open Source Community is filled with lovely people who have keep this updated and documented!

Special thanks to:

Installation

This loader need nunjucks as a peer dependency. Versions >= 2.5.0 <= 4.0.0 are accepted. If you do not have nunjucks already installed, first run:

Using yarn:

yarn add nunjucks -D

Using npm:

npm install nunjucks -D

If you have nunjucks installed, you can then install the loader.

Using yarn:

yarn add nunjucks-isomorphic-loader -D

Using npm:

npm install nunjucks-isomorphic-loader -D

Usage

Basic usage of this loader with html-webpack-plugin

module: {
  rules: [
    {
      test: /\.(njk|nunjucks|html|tpl|tmpl)$/,
      use: [
        {
          loader: 'nunjucks-isomorphic-loader',
          query: {
            root: [path.resolve(__dirname, 'path/to/templates/root')]
          }
        }
      ]
    }
  ]
},

plugins: [
  new HtmlWebpackPlugin({
    customData: { foo: 'bar' },
    filename: 'list.html',
    template: 'path/to/template.njk'
  })
]

Accessing data from the templates with the above config of html-webpack-plugin

path/to/template.njk :

{% set vars = htmlWebpackPlugin.options.customData %}

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>{{ vars.foo }}</title>{# outputs 'bar' #}
  </head>
  <body>
    <header class="header">
    {% block header %}
      <h1 class="header-logo">
        <a >{{ vars.foo }}</a>{# outputs 'bar' #}
      </h1>
    {% endblock %}
    </header>

    {% block content %}
      <section>
        <p>I was generated with html-webpack-plugin and nunjucks-isomorphic-loader!</p>
      </section>
    {% endblock %}
  </body>
</html>

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].