Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wmluke/angular-blocks

Template inheritance for Angular JS
https://github.com/wmluke/angular-blocks

Last synced: 5 days ago
JSON representation

Template inheritance for Angular JS

Awesome Lists containing this project

README

        

# angular-blocks

[![Build Status](https://travis-ci.org/wmluke/angular-blocks.png?branch=master)](https://travis-ci.org/wmluke/angular-blocks)
[![Coverage Status](https://coveralls.io/repos/wmluke/angular-blocks/badge.png?branch=master)](https://coveralls.io/r/wmluke/angular-blocks?branch=master)

Block style template inheritance for [AngularJS](http://angularjs.org) inspired by [Jade](http://jade-lang.com), [Handlebars](http://thejohnfreeman.com/blog/2012/03/23/template-inheritance-for-handlebars.html), and [Django](https://docs.djangoproject.com/en/dev/topics/templates/#template-inheritance).

## Installation

Requires jquery.

Download [angular-blocks.min.js](https://github.com/wmluke/angular-blocks/blob/master/dist/angular-blocks.min.js) or install with bower.

```bash
$ bower install angular-blocks --save
```

Load `angular-blocks.min.js` then add the `angular-blocks` module to your Angular app.

```javascript
angular.module('app', ['angular-blocks']);
```

## Usage

Given the template below:

```html

<header data-block="header">
<p>:header</p>
</header>
<div data-block="content">
<p>:content</p>
</div>
<footer data-block="footer">
<p>:footer</p>
</footer>

```

### Block Replace: `data-block`

```html



Foo




```

Becomes:

```html



:header




Foo




:footer




```

### Block Prepend: `data-block-prepend`

```html



Foo




```

Becomes:

```html



:header





Foo



:content




:footer




```

### Block Append: `data-block-append`

```html



Foo




```

Becomes:

```html



:header




:content



Foo





:footer




```

### Block Before: `data-block-before`

```html



Foo




```

Becomes:

```html



:header




Foo




:content




:footer




```

### Block After: `data-block-after`

```html



Foo




```

Becomes:

```html



:header




:content




Foo




:footer




```

## API

See the [spec](https://github.com/wmluke/angular-blocks/blob/master/test/angular-blocks-spec.js).

## Contributing

### Prerequisites

The project requires [Bower](http://bower.io), [Grunt](http://gruntjs.com), and [PhantomJS](http://phantomjs.org). Once you have installed them, you can build, test, and run the project.

### Build & Test

To build and run tests, run either...

```bash
$ make install
```

or

```bash
$ npm install
$ bower install
$ grunt build
```

## Licsense

Copyright (c) 2013 William L. Bunselmeyer. https://github.com/wmluke/angular-blocks

Licensed under the MIT License