2.0.3 • Published 6 years ago

@abcum/ember-domain v2.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

ember-domain

A utility for detecting the active route and domain properties in Ember.js.

npm.io npm.io npm.io npm.io npm.io npm.io

Usage

Installation

ember install @abcum/ember-domain

Introduction

The ember-domain addon enables responding to changes to the current ember.js route, and the detection and tracking of changes to the window.location object. This enables customisation of behaviour and styling depending on the current route or domain path.

The current ember.js route is attached to the html body, enabling css styling based on detection of the body attr, whilst the full domain object is made available inside all routes, controllers, and components.

Examples

Displaying the current url.

{{domain.href}}

Using the current route info inside css stylesheets.

body[route="posts.index"] div {
	/* Custom styles for the 'posts.index' route */
}
body[route=^"posts.post"] div {
	/* Custom styles for the 'posts.post.*' routes */
}

Using the current route info inside an Ember controller.

export default Ember.Controller.extend({
	breadcrumb: Ember.computed('domain.route', function() {
		// Do something with the current route
		return this.get('domain.route').split('.');
	})
})

Using the current route info inside handlebars templates.

<div class="menu">
	<li class="{{if (eq domain.route 'posts.index') 'selected'}}">
		Posts
	</li>
	<li class="{{if (eq domain.route 'users.index') 'selected'}}">
		Users
	</li>
	<li class="{{if (eq domain.route 'settings.index') 'selected'}}">
		Settings
	</li>
</div>

Properties

The following properties are available.

Object propertyExample output
domain.routeposts.post.index
domain.fullwindow.location ...
domain.hrefhttp://localhost:4200/posts/123?sort=true#test
domain.hostlocalhost
domain.port4200
domain.path/posts/123
domain.vars?sort=true
domain.hashtest

Development

  • make install (install bower and ember-cli dependencies)
  • make upgrade (upgrade ember-cli to the specified version)
  • make tests (run all tests defined in the package)
2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.1

7 years ago

1.0.0

7 years ago