0xBADC0FFEE / tower-directive

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This repository is a mirror of the component module tower/directive. It has been modified to work with NPM+Browserify. You can install it using the command npm install npmcomponent/tower-directive. Please do not open issues or send pull requests against this repo. If you have issues with this repo, report it to npmcomponent.

Tower Directive

API to the DOM. Tells the DOM what to do.

Installation

$ component install tower/directive

Examples

var directive = require('tower-directive');

directive('data-text', function(scope, element, attr){
  element.textContent = scope[attr.value];
});

var content = { foo: 'Hello World' };
var element = document.querySelector('#example');

directive('data-text').exec(content, element);
<span id="example" data-text="foo"></span>

becomes:

<span id="example" data-text="foo">Hello World</span>

The directives are used more robustly in tower-template.

API

exec(content, element)

This one must be exact to maximize performance.

directive.exec(content, element)

Globally execute all directives.

directive.exec(content)

directive.exec(element)

directive.exec()

Running Tests

Install testem:

$ npm install -g testem

Install Node Packages:

$ npm link

Install Components:

$ component install -d

Run tests:

$ testem

Then, open all the browsers you want to test by going to the outputted url defaulted to http://localhost:7357

Tests will run on any open browser linked to the stated url and your current Node environment.

Contributing

Before you send a pull request, make sure your code meets the style guidelines at https://github.com/tower/style-guide and all tests pass.

Notes

License

MIT

About