Skip to content

🔬 Link controllers to partials and (optionally) limit the scope of the viewModel

License

Notifications You must be signed in to change notification settings

taunus/taunus-actions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

taunus-actions

Link controllers to partials and (optionally) limit the scope of the viewModel

Install

npm install taunus-actions --save

Setup

Use actions.configure to give taunus-actions a reference of your taunus object to set it up.

var actions = require('taunus-actions');

actions.configure({
  taunus: taunus
});

Usage

Imagine you have this piece of markup which represents a user's profile. And you want to have a controller linked to it. Then you can use the data-taunus-action property to specify which controller to link to. Also, you can (optionally) use the data-taunus-model property which allows you to provide only part of the viewModel to the linked controller.

<div class="user-profile" data-taunus-action="user/profile" data-taunus-model="user">
  <img src="{{ user.picture }}" alt="{{ user.name }}">
  <span>{{ user.name }}</span>
</div>

So, if the viewModel is something like:

{
  "foo": "bar",
  "baz": [],
  "user": {
    "name": "John Doe",
    "picture": "https://www.gravatar.com/avatar/foo"
  }
}

The user/profile controller will get just:

{
  "name": "John Doe",
  "picture": "https://www.gravatar.com/avatar/foo"
}

About

🔬 Link controllers to partials and (optionally) limit the scope of the viewModel

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published