Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs & minor fix #111

Merged
merged 1 commit into from
Apr 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Load Paper into your app:

```
var Paper = require('stencil-paper');
var Paper = require('@bigcommerce/stencil-paper');
```

Instatiate paper passing an `assembler`:
Expand Down
58 changes: 53 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,66 @@ Fs.readdirSync(Path.join(__dirname, 'helpers')).forEach(function (file) {
});

/**
* Theme renderer constructor
* @param {Object} settings
* @param {Object} themeSettings
* @param {Object} assembler
* processor is an optional function to apply during template assembly. The
* templates parameter is a object where the keys are paths and the values are the
* raw templates. The function returns an object of the same format, possibly changing
* the values. We use this to precompile templates within the Paper module.
*
* @callback processor
* @param {Object} templates - Object that contains the gathered templates
*/

/**
* getTemplatesCallback is a function to call on completion of Assembler.getTemplates
*
* @callback getTemplatesCallback
* @param {Error} err - Error if it occurred, null otherwise
* @param {Object} templates - Object that contains the gathered templates, including processing
*/

/**
* getTranslationsCallback is a function to call on completion of Assembler.getTranslations
*
* @callback getTranslationsCallback
* @param {Error} err - Error if it occurred, null otherwise
* @param {Object} translations - Object that contains the translations
*/

/**
* Assembler.getTemplates assembles all the templates required to render the given
* top-level template.
*
* @callback assemblerGetTemplates
* @param {string} path - The path to the templates, relative to the templates directory
* @param {processor} processor - An optional processor to apply to each template during assembly
* @param {getTemplatesCallback} callback - Callback when Assembler.getTemplates is done.
*/

/**
* Assembler.getTranslations assembles all the translations for the theme.
*
* @callback assemblerGetTranslations
* @param {getTranslationsCallback} callback - Callback when Assembler.getTranslations is done.
*/

/**
* Paper constructor. In addition to store settings and theme settings (configuration),
* paper expects to be passed an assembler to gather all the templates required to render
* the top level template.
*
* @param {Object} settings - Site settings
* @param {Object} themeSettings - Theme settings (configuration)
* @param {Object} assembler - Assembler with getTemplates and getTranslations methods.
* @param {assemblerGetTemplates} assembler.getTemplates - Method to assemble templates
* @param {assemblerGetTranslations} assembler.getTranslations - Method to assemble translations
*/
function Paper(settings, themeSettings, assembler) {
var self = this;

self.handlebars = Handlebars.create();

self.handlebars.templates = {};
self.translate = null;
self.translator = null;
self.inject = {};
self.decorators = [];

Expand Down