paperclip-view ==============

npm install paperclip-component
77 downloads in the last day
204 downloads in the last week
543 downloads in the last month

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.



  • Node: npm install paperclip-component
  • Browser: bower install paperclip-component


You'll first need to add paperclip-component as a plugin:

var pc   = require("paperclip"),
pcc      = require("paperclip-component"),
bindable = require("bindable");

//where global components live.
var components = new bindable.Object();

//plugin paperclip-components, and point to the components dictionary

After you have that setup, you can start registering components. Here's one specific to a node.js application:

components.set("mainLayout", require("./mainLayout"));


var mojo = require("mojojs"),
structr  = require("structr"),
pc       = require("paperclip")

var MainLayoutView = structr(mojo.View, {
  paper: pc.load(__dirname + "/mainLayout.pc")

module.exports = MainLayoutView;


    {{ 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:


  {{#sections: "body" }}
    Hello World!

The rendered output of hello.pc would be:

    Hello World!
npm loves you