-
Notifications
You must be signed in to change notification settings - Fork 105
Panini 2.0 Preview
Geoff Kimball edited this page Jun 14, 2017
·
1 revision
This is a work in progress.
The second version of Panini will bring it up to punching weight with other static site tools.
-
Cross-referencing pages: a page has access to a
pages
variable, which is an array of metadata on all pages in the site. With this, you can dynamically generate navigation.
-
More format support: data files can now be JSON, YAML, CSON, or a
.js
file withmodule.exports
. A JavaScript file can also be a function that returns data, or an asynchronous function that returns a Promise containing data. - Deep merging of page data. when page-specific data is combined with global data, objects are deeply merged.
-
Translation strings: locale-specific data files containing translation strings can be created. Within pages, the
{{translate}}
helper allows you to reference a specific string. -
Automatic page generation: when you create multiple locales for your site, each page will be rendered multiple times and dropped into folders for each locale, i.e.
/en/index.html
,/is/index.html
. -
Locale-specific pages: a page can be placed into a locale-specific folder, such as
/en/about.hbs
, and that page will not be translated into other languages.
- Pug and EJS support: in addition to the default of Handlebars, the rendering engine can also be switched to Pug or EJS.
- More built-in helpers: for Pug and EJS, the template-helpers library is built-in. For Handlebars, the more specific handlebars-helpers library is included. This means each engine has access to over a hundred helper functions out of the box.
-
No configuration required: the only things you need to run Panini are input and output folders. By default, Panini will look for pages, layouts, partials, etc. in default folder names:
pages
,layouts
,partials
, etc.
A better programmatic API has been added.
const Panini = require('panini');
const p = new Panini('src', 'dist');
// Build once
await p.build();
console.log('Build done.');
// Build and watch for changes
p.watch();
The CLI has been simplified. You just specify input and output folders, and optionally a --watch
flag.
$ panini src dist
Options can be set with a panini
key on your project's package.json
.
- Configuration
- Instead of defining globs of files to pick up (e.g.,
src/pages/**/*.html
, a folder is set instead (e.g., justpages
). - Folders for specific features (pages, layouts, partials, etc.) must now be immediate subfolders of the root project folder.
- Removed the ability to specify multiple folders per feature with an array.
- Instead of defining globs of files to pick up (e.g.,
- Handlebars
-
#ifPage
and#unlessPage
have been replaced by the more genericcurrentPage
, which returns a boolean. -
#code
has been replaced by#highlight
in handlebars-helpers. -
#ifEqual
has been replaced byeq
in handlebars-helpers.
-