1 | # stencil-paper
|
2 | [![Build Status](https://travis-ci.org/bigcommerce/paper.svg?branch=master)](https://travis-ci.org/bigcommerce/paper) [![npm (scoped)](https://img.shields.io/npm/v/@bigcommerce/stencil-paper.svg)](https://www.npmjs.com/package/@bigcommerce/stencil-paper)
|
3 |
|
4 | *stencil-paper* is a plugin for `stencil-cli` and `stapler`. Its duty is to render the themes using [Handlebars](http://handlebarsjs.com/) template engine.
|
5 |
|
6 | ## Usage
|
7 |
|
8 | Load Paper into your app:
|
9 |
|
10 | ```
|
11 | var Paper = require('@bigcommerce/stencil-paper');
|
12 | ```
|
13 |
|
14 | Instatiate paper passing an `assembler`:
|
15 | ```
|
16 | var paper = new Paper(assembler);
|
17 | ```
|
18 |
|
19 | The `assembler` is the interface that paper uses to load the templates and translations. This way we can use paper to load the templates from the file system or any other source.
|
20 | Is just an object that implements two methods: `getTemplates()` & `getTranslations()`:
|
21 | ```
|
22 | var assembler = {
|
23 | getTemplates: function (path, processor, callback) {
|
24 | // inplement me
|
25 |
|
26 | callback(null, processor(templates));
|
27 | },
|
28 | getTranslations: function (callback) {
|
29 | // inplement me
|
30 |
|
31 | callback(null, translations);
|
32 | }
|
33 | };
|
34 |
|
35 | var paper = new Paper(assembler);
|
36 | ```
|
37 |
|
38 | Now we can load the theme for the page we want to render:
|
39 | ```
|
40 | paper.loadTheme(path, 'en', function (err) {
|
41 | var html = paper.render(path, context);
|
42 |
|
43 | reply(html);
|
44 | });
|
45 | ```
|
46 |
|
47 | ## Helpers Reference
|
48 | See the [stencil API reference](https://stencil.bigcommerce.com/docs/handlebars-helpers-reference) for documentation on the available helpers.
|
49 |
|
50 | #### License
|
51 |
|
52 | Copyright (c) 2015-2016, Bigcommerce Inc.
|
53 | All rights reserved.
|
54 |
|
55 | Redistribution and use in source and binary forms, with or without
|
56 | modification, are permitted provided that the following conditions are met:
|
57 | 1. Redistributions of source code must retain the above copyright
|
58 | notice, this list of conditions and the following disclaimer.
|
59 | 2. Redistributions in binary form must reproduce the above copyright
|
60 | notice, this list of conditions and the following disclaimer in the
|
61 | documentation and/or other materials provided with the distribution.
|
62 | 3. All advertising materials mentioning features or use of this software
|
63 | must display the following acknowledgement:
|
64 | This product includes software developed by Bigcommerce Inc.
|
65 | 4. Neither the name of Bigcommerce Inc. nor the
|
66 | names of its contributors may be used to endorse or promote products
|
67 | derived from this software without specific prior written permission.
|
68 |
|
69 | THIS SOFTWARE IS PROVIDED BY BIGCOMMERCE INC ''AS IS'' AND ANY
|
70 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
71 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
72 | DISCLAIMED. IN NO EVENT SHALL BIGCOMMERCE INC BE LIABLE FOR ANY
|
73 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
74 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
75 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
76 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
77 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
78 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|