Paperclip-components allows you to break up your paperclip views into separate files, and re-use them in other parts of your application. This idea was derrived from Ember Components, and Angular Directives.
Requirements
- bindable.js - needed for registering components
- NPM, or Bower - used to install
paperclip-compoennt
- paperclip
Installation
- Node:
npm install paperclip-component
- Browser:
bower install paperclip-component
Usage
You'll first need to add paperclip-component
as a plugin:
var pc = pcc = bindable = ; //where global components live.var components = ; //plugin paperclip-components, and point to the components dictionarypc;
After you have that setup, you can start registering components. Here's one specific to a node.js
application:
components;
mainLayout.js:
var mojo = structr = pc = var MainLayoutView = ; moduleexports = MainLayoutView;
mainLayout.pc:
{{ html: sections.body }}
After you've defined your component, you can use it in any template. Here's how you might use mainLayout
in a .pc
file:
hello.pc:
{{#mainLayout}} {{#sections: "body" }} Hello World! {{/}}{{/}}
The rendered output of hello.pc
would be:
Hello World!