diff --git a/README.md b/README.md
index 94cd157b35..922b8b4267 100644
--- a/README.md
+++ b/README.md
@@ -227,6 +227,7 @@ search.addWidget(
// page: number
// processingTimeMS: number
// query: string
+ transformData: // function to modify the data passed to the template
})
);
```
@@ -312,7 +313,11 @@ search.addWidget(
hit // string (mustache format) or function(hit) return string
},
hitsPerPage: 20,
- // cssClass
+ // cssClass,
+ // transformData: {
+ // empty, // function to modify the data passed to the empty template
+ // hit // function to modify the data passed to the hit template
+ // }
})
);
```
@@ -356,6 +361,7 @@ search.addWidget(
* @param {String} options.facetName Name of the attribute for faceting (eg. "free_shipping")
* @param {String} options.label Human-readable name of the filter (eg. "Free Shipping")
* @param {String|Function} [options.template] Item template, provided with `label` and `isRefined`
+ * @param {Function} [options.transformData] Function to change the object passed to the item template
* @param {boolean} [hideIfEmpty=true] Hide the container when no results match
* @return {Object}
*/
@@ -386,6 +392,7 @@ search.addWidget(
{{name}} {{count}}
`] Item template, provided with `name`, `count`, `isRefined`
* @param {String|Function} [options.templates.footer] Footer template
+ * @param {Function} [options.transformData] Function to change the object passed to the item template
* @param {String|Function} [options.singleRefine=true] Are multiple refinements allowed or only one at the same time. You can use this
* to build radio based refinement lists for example
* @param {boolean} [hideIfEmpty=true] Hide the container when no results match
@@ -431,6 +438,7 @@ search.addWidget(
* @param {String|Function} [options.templates.header=''] Header template
* @param {String|Function} [options.templates.item='{{name}} {{count}}'] Item template, provided with `name`, `count`, `isRefined`
* @param {String|Function} [options.templates.footer=''] Footer template
+ * @param {Function} [options.transformData] Function to change the object passed to the item template
* @param {boolean} [hideIfEmpty=true] Hide the container when no results match
* @return {Object}
*/
diff --git a/components/Hits.js b/components/Hits.js
index 6774848a24..832a9d82f9 100644
--- a/components/Hits.js
+++ b/components/Hits.js
@@ -5,16 +5,36 @@ var Template = require('./Template');
class Hits extends React.Component {
renderWithResults() {
+ var template = this.props.hitTemplate;
+ var transformData = this.props.hitTransformData;
+
var renderedHits = map(this.props.hits, function(hit) {
- return ;
+ return (
+
+ );
}, this);
return
{renderedHits}
;
}
renderNoResults() {
+ var data = this.props.results;
+ var template = this.props.noResultsTemplate;
+ var transformData = this.props.noResultsTransformData;
+
return (
-
+