Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
panini
✓ import panini from 'panini';
✗ const panini = require('panini');
Panini is a CommonJS module and does not provide ESM exports. Using require() is correct; there is no default import in ESM style.
panini.refresh
✓ const panini = require('panini');
panini.refresh();
✗ import { refresh } from 'panini';
refresh() is a method on the main panini object, not a named export. Use require('panini') and call panini.refresh().
Panini (constructor)
✓ const Panini = require('panini');
const instance = new Panini(options);
✗ const { Panini } = require('panini');
The module exports a constructor function directly, not a named export. Use require() to get the constructor.
Shows a basic Gulp task using Panini to compile HTML pages with layouts, partials, helpers, data, and a watch that refreshes Panini on changes.
const gulp = require('gulp');
const panini = require('panini');
gulp.task('build', function() {
return gulp.src('src/pages/**/*.html')
.pipe(panini({
root: 'src/pages/',
layouts: 'src/layouts/',
partials: 'src/partials/',
helpers: 'src/helpers/',
data: 'src/data/',
pageLayouts: {
'blog': 'blog'
}
}))
.pipe(gulp.dest('dist'));
});
gulp.watch(['src/{layouts,partials,helpers,data}/**/*'], function() {
panini.refresh();
});
Errors
Common errors & fixes
Error: Layout not found: default
Panini expects a layout file named 'default.html' (or .hbs/.handlebars) in the specified layouts folder. If missing, this error occurs.
fixCreate a file named 'default.html' in your layouts folder, or ensure the layouts option points to the correct folder.
TypeError: Cannot read property 'partials' of undefined
This error can occur if the partials folder path is incorrect or does not exist. Panini tries to load partials and fails silently, but accessing the partial may cause this.
fixVerify that the partials folder exists and is correctly specified in the options. Ensure files inside have .html, .hbs, or .handlebars extension.
Error: Failed to load data file: unexpected token
Panini uses js-yaml to parse YAML files. An invalid YAML syntax (e.g., indentation errors) will cause this error.
fixValidate your YAML files using a YAML linter. Ensure proper indentation and syntax.
Audit
Dependencies
handlebarsrequiredHandlebars is the templating engine used by Panini for layouts and partials. Panini v1.3.0 upgraded from Handlebars 3 to 4, which introduced breaking changes around raw block execution context.
gulprequiredPanini is designed as a Gulp plugin; it expects a Gulp stream as input and returns a transformed stream. Without Gulp, Panini cannot be used as intended.