devongovett/pdfkit — pull request #56 by alFReD-NSH (2011-12-25 09:08:41+00:00)
Title: Add templating feature

This is a nice feature that we can build static parts of a PDF file before, save them, and then later on we put them on the dynamic content for everypage. Though the way I implemented it may not be the best(for example you can switch pages, which you should not, or maybe the fonts may not work), but at the moment it basically works:

I added these functions to public API:

* `startTemp()` -> starts the templating mode

* `endTemp()` -> ends the templating mode

* `outputTemp()` -> which will outputs the template

I added an argument to the end of the constructor function:

* `constructor: (@options = {}, temp)` in which temp is object that is returned by `outputTemp()`

Beside that 3 variables:

* haveTemp: false

* isTemp: false

* temp -> which holds the template object

But this is just a work in progress. I'm thinking of adding features such as, building on a pre-built file, or having multiple templates.