Socket
Book a DemoInstallSign in
Socket

@aller/mustachejs-loader

Package Overview
Dependencies
Maintainers
14
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aller/mustachejs-loader

Mustache.js loader for webpack

latest
Source
npmnpm
Version
0.3.1
Version published
Weekly downloads
0
Maintainers
14
Weekly downloads
 
Created
Source

mustachejs-loader

A loader for webpack that uses mustache.js package.

Getting started

To begin, you'll need to install mustache and mustachejs-loader:

Yarn

$ yarn add --dev mustache mustachejs-loader

Npm

$ npm install mustache mustachejs-loader --save-dev

Webpack config

module: {
  rules: [
    {
      test: /\.mustache$/,
      loader: '@aller/mustachejs-loader'
    }
  ]
}

mustache files

{{! template.mustache }}
<h1>{{ variable }}</h1>
{{ > partial }}
{{! partial.mustache }}
<h2>{{ partialText }}</h2>

files.js

import template from 'template.mustache'

const html = template()
import template from 'template.mustache'

const html = template({ variable: "Hello world!" })

With partials

import template from 'template.mustache'
import { templateString } from 'partial.mustache'

const html = template(
  { variable: "Hello world!", partialText: "Sup?" },
  { partial: templateString }
)

Will produce the following HTML

<h1>Hello world!</h1>
<h2>Sup?</h2>

Partial loader

Webpack config

module: {
  rules: [
    {
      test: /\.mustache$/,
      loader: [
        '@aller/mustachejs-loader',
        '@aller/mustachejs-partial-loader',
      ]
    }
  ]
}

The @aller/mustachejs-partial-loader by default fetches all the files with the suffix .mustache from the ./partials directory.

To see available options for the partial loader click here

Keywords

webpack

FAQs

Package last updated on 05 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts