Implements a generation callback druck.on('generated', function(event) { ... }) with event providing access to {dest, source (not the original source!), locals, rendered, ...custom props}.
The interface from Generator.generate was extended in that it returns the generated output. Additionally, this commit upgrades chai to the latest stable as the functionality expect(result).to.contain.all.keys('dest', 'source', 'rendered', 'locals', 'myCustomProp'); was desired.
General observations:
It is to some extend unpredictable what outcome will be available in the callback's argument (but also within the generator#generate) without having knowledge of the internals and the templates. This is for the following reasons:
The rather arguable design decision to implement pagination via locals.items. This value could easily be overridden page/template internally via the front-matter and/or the latter has no effect.
Also, the Kartoffeldruck.prototype.generate method as it stands now provides quite some unexpected behavior:
it discards pagination: 1 property (and probably some others, but which?)
it overrides initial source, which forces the author to specify it twice in the hash provided as options if required within the event callback
Implements a generation callback
druck.on('generated', function(event) { ... })
withevent
providing access to{dest, source (not the original source!), locals, rendered, ...custom props}
.The interface from
Generator.generate
was extended in that it returns the generated output. Additionally, this commit upgrades chai to the latest stable as the functionalityexpect(result).to.contain.all.keys('dest', 'source', 'rendered', 'locals', 'myCustomProp');
was desired.General observations: It is to some extend unpredictable what outcome will be available in the callback's argument (but also within the generator#generate) without having knowledge of the internals and the templates. This is for the following reasons:
The rather arguable design decision to implement pagination via
locals.items
. This value could easily be overridden page/template internally via the front-matter and/or the latter has no effect.Also, the
Kartoffeldruck.prototype.generate
method as it stands now provides quite some unexpected behavior:pagination: 1
property (and probably some others, but which?)