Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 5094399b7aeaa2a5c5edba1fe24ef17cc4de1015 2 parents 0848e61 + 170b5ea
Paolo Fragomeni authored
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
8 README.md
@@ -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
2  test/api-test.js
@@ -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
24 test/browser.html
@@ -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>
Please sign in to comment.
Something went wrong with that request. Please try again.