Permalink
Browse files

Merge branch 'master' of github.com:flatiron/plates

  • Loading branch information...
2 parents 0848e61 + 170b5ea commit 5094399b7aeaa2a5c5edba1fe24ef17cc4de1015 Paolo Fragomeni committed Aug 25, 2012
Showing with 31 additions and 3 deletions.
  1. +6 −2 README.md
  2. +1 −1 test/api-test.js
  3. +24 −0 test/browser.html
View
@@ -195,14 +195,18 @@ the attribute that was specified in the `where` clause.
```
function Map#use(key)
-@param key {String} A string that represents a key in the data object that was provided.
+@param key {String|Function} A string that represents a key in the data object that was provided or a function which returns a string value to use.
+
+If a function is provided, it will be passed data, value and tagbody parameters.
```
### to()
```
function Map#to(key)
-@param key {String} A string that represents a key in the data object that was provided.
+@param key {String|Function} A string that represents a key in the data object that was provided or a function which returns a string value to use.
+
+If a function is provided, it will be passed data, value and tagbody parameters.
Same as `use` method.
```
View
@@ -322,7 +322,7 @@ vows.describe('merge data into markup').addBatch({
}()
),
- '(30) a tag match without attributes should replace the contents': (
+ '(30) use can be passed a function which returns the value': (
function() {
var map = Plates.Map();
View
@@ -484,6 +484,20 @@ <h3 class="name">FooBar</h3>
<div id="key1" style="visible: foobar > 1">value1</div>
</script>
+
+<script type="test/fixture" id="test-30.json">
+{ "uppercase": "UPPERCASED" }
+
+</script>
+<script type="test/fixture" id="test-30.html">
+<div class="transformation"></div>
+
+</script>
+<script type="test/fixture" id="test-30.out">
+<div class="transformation">uppercased</div>
+
+</script>
+
<script type="test/fixture" id="test-4.html">
<a id="someid" src="google.com"></a>
<a id="someotherid" src="yahoo.com"></a>
@@ -806,4 +820,14 @@ <h3 class="name">FooBar</h3>
return common.createTest('test-29', map);
});
+
+test("(30) use can be passed a function which returns the value", function() {
+ var map = Plates.Map();
+ map.class('transformation').use(function (data, key) {
+ return data.uppercase.toLowerCase();
+ });
+
+ return common.createTest('test-30', map);
+});
+
</script>

0 comments on commit 5094399

Please sign in to comment.