Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
rivets
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
5b6f9ed2
authored
2012-07-25 13:53:54 +1000
by
Paul Jones
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Look for formatters on model object too
1 parent
237f7d9b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
1 deletions
spec/rivets/binding.js
src/rivets.coffee
spec/rivets/binding.js
View file @
5b6f9ed
...
...
@@ -15,6 +15,7 @@ describe('Rivets.Binding', function() {
el
.
setAttribute
(
'data-text'
,
'obj.name'
);
view
=
rivets
.
bind
(
el
,
{
obj
:
{}});
binding
=
view
.
bindings
[
0
];
model
=
binding
.
model
;
});
it
(
'gets assigned the routine function matching the identifier'
,
function
()
{
...
...
@@ -72,6 +73,12 @@ describe('Rivets.Binding', function() {
binding
.
formatters
.
push
(
'awesome'
);
expect
(
binding
.
formattedValue
(
'hat'
)).
toBe
(
'awesome hat'
);
});
it
(
'uses formatters on the model'
,
function
()
{
model
.
modelAwesome
=
function
(
value
)
{
return
'model awesome '
+
value
};
binding
.
formatters
.
push
(
'modelAwesome'
);
expect
(
binding
.
formattedValue
(
'hat'
)).
toBe
(
'model awesome hat'
);
});
describe
(
'with a multi-argument formatter string'
,
function
()
{
beforeEach
(
function
()
{
...
...
src/rivets.coffee
View file @
5b6f9ed
...
...
@@ -26,7 +26,7 @@ class Rivets.Binding
for
formatter
in
@
formatters
args
=
formatter
.
split
/\s+/
id
=
args
.
shift
()
value
=
Rivets
.
config
.
formatters
[
id
]
value
,
args
...
value
=
(
Rivets
.
config
.
formatters
[
id
]
||
@
model
[
id
])
value
,
args
...
value
...
...
Please
register
or
sign in
to post a comment