batmanjs/batman — pull request #984 by sdomino (2014-02-25 23:16:41+00:00)
Title: addng some better context selection to views

This is a pretty simple change, but it's been pretty nice. While there is the @context, sometimes its nice to be able to specifically target which parent you want to modify for both setting and getting rather than relying on @context bubbling.

View to View:
```
// some nested view
@context.get 'SomeParentView.value'
@context.set 'OtherParentView', true

VS.

// some nested view
@context.get 'parent.parent.parent.someValue'
@context.set 'parent.parent.parent.otherValue', true
```

Direct on-the-fly getting/setting:
```
.batman.view{ data: { view: 'ParentView' } }
%div{ data: { showif: 'value' } } Show me
%div{ data: { 'event-click' => 'ParentView.set | withArguments "value", true' } } Show parent
%div{ data: { 'event-click' => 'ParentView.unset | withArguments "value"' } } Hide parent
```

Especially nice with nested views:
```
.batman.view{ data: { view: 'ParentView' } }
%div{ data: { showif: 'value' } } Show me

.batman.view{ data: { view: 'ChildView' } }
%div{ data: { showif: 'ParentView.value' } } Will show me
%div{ data: { showif: 'ChildView.value' } } Wont show me
%div{ data: { 'event-click' => 'ParentView.set | withArguments "value", true' } } Show parent
%div{ data: { 'event-click' => 'ParentView.unset | withArguments "value"' } } Show parent
```

While these examples are completely contrived I think they illustrate the possibilities. While its always important to make sure your variables are unique within the same scope/context to avoid 'collisions', this just adds a level of clarity/directness that comes in handy sometimes.