Pop 0.0.5
Pop 0.0.5 has been released. This version introduces a plugin architecture and post-filters.
Post-Filters
A post-filter can alter HTML after it has been generated by the template engine. The structure is the same as helpers and pre-filters. Add a file to _lib/post-filters.js:
module.exports = {
/**
* Converts Alex's name to something more suitable.
*
* @param {String} The HTML to transform
* @return {String} The transformed HTML
*/
myFilter: function(html) {
return html.replace(/Alex/, 'Super Douche');
}
};
Using Plugins
Plugins are bundles of helpers, pre-filters, and post-filters that are loaded using the config file. Here's an example, from this site:
{ "url": "http://popjs.com/"
, "title": "Pop Blog"
, "permalink": "/:year/:month/:day/:title"
, "paginate": 10
, "exclude": ["\\.swp"]
, "require": ["pop-disqus"]
, "autoGenerate": [{"feed": "feed.xml"}] }
The require property loads the plugin found in the CommonJS module pop-disqus. This plugin is available through npm.
Writing Plugins
Create a CommonJS module with a suitable package.json that exports an object with one or more of these properties:
helpersfilterspostFilters
All the usual rules apply. Get started by looking at pop-disqus. Write tests, even if they're basic!