UNPKG

3.17 kBMarkdownView Raw
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
8Load Paper into your app:
9
10```
11var Paper = require('@bigcommerce/stencil-paper');
12```
13
14Instatiate paper passing an `assembler`:
15```
16var paper = new Paper(assembler);
17```
18
19The `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.
20Is just an object that implements two methods: `getTemplates()` & `getTranslations()`:
21```
22var 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
35var paper = new Paper(assembler);
36```
37
38Now we can load the theme for the page we want to render:
39```
40paper.loadTheme(path, 'en', function (err) {
41 var html = paper.render(path, context);
42
43 reply(html);
44});
45```
46
47## Helpers Reference
48See the [stencil API reference](https://stencil.bigcommerce.com/docs/handlebars-helpers-reference) for documentation on the available helpers.
49
50#### License
51
52Copyright (c) 2015-2016, Bigcommerce Inc.
53All rights reserved.
54
55Redistribution and use in source and binary forms, with or without
56modification, are permitted provided that the following conditions are met:
571. Redistributions of source code must retain the above copyright
58 notice, this list of conditions and the following disclaimer.
592. 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.
623. 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.
654. 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
69THIS SOFTWARE IS PROVIDED BY BIGCOMMERCE INC ''AS IS'' AND ANY
70EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
71WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
72DISCLAIMED. IN NO EVENT SHALL BIGCOMMERCE INC BE LIABLE FOR ANY
73DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
74(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
75LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
76ON 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
78SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.