diff --git a/src/reactTemplates.js b/src/reactTemplates.js
index 120cd60..55b1c29 100644
--- a/src/reactTemplates.js
+++ b/src/reactTemplates.js
@@ -116,6 +116,7 @@ function generateInjectedFunc(context, namePrefix, body, params) {
}
function generateTemplateProps(node, context) {
+ let templatePropCount = 0;
const propTemplateDefinition = context.options.propTemplates[node.name];
const propertiesTemplates = _(node.children)
.map((child, index) => {
@@ -141,7 +142,7 @@ function generateTemplateProps(node, context) {
}
if (templateProp) {
- _.assign(templateProp, {childIndex: index, content: _.find(child.children, {type: 'tag'})});
+ _.assign(templateProp, {childIndex: index - templatePropCount++, content: _.find(child.children, {type: 'tag'})});
}
return templateProp;
diff --git a/test/data/propTemplates/siblingTemplates.rt b/test/data/propTemplates/siblingTemplates.rt
new file mode 100644
index 0000000..21204d7
--- /dev/null
+++ b/test/data/propTemplates/siblingTemplates.rt
@@ -0,0 +1,12 @@
+
+
+ Brother: {brother}
+
+
+ Sister: {sister}
+
+
Separator
+
+ Other: {other}
+
+
diff --git a/test/data/propTemplates/siblingTemplates.rt.js b/test/data/propTemplates/siblingTemplates.rt.js
new file mode 100644
index 0000000..58f5009
--- /dev/null
+++ b/test/data/propTemplates/siblingTemplates.rt.js
@@ -0,0 +1,22 @@
+define([
+ 'react',
+ 'lodash'
+], function (React, _) {
+ 'use strict';
+ function templateProp11(brother) {
+ return React.createElement('div', {}, 'Brother: ', brother);
+ }
+ function templateProp22(sister) {
+ return React.createElement('div', {}, 'Sister: ', sister);
+ }
+ function templateProp33(other) {
+ return React.createElement('div', {}, 'Other: ', other);
+ }
+ return function () {
+ return React.createElement('div', {
+ 'templateProp1': templateProp11.bind(this),
+ 'templateProp2': templateProp22.bind(this),
+ 'templateProp3': templateProp33.bind(this)
+ }, React.createElement('div', {}, 'Separator'));
+ };
+});
diff --git a/test/src/rt.valid.spec.js b/test/src/rt.valid.spec.js
index 7ceff23..5eb01f7 100644
--- a/test/src/rt.valid.spec.js
+++ b/test/src/rt.valid.spec.js
@@ -49,7 +49,13 @@ module.exports = {
},
modules: 'amd'
};
- const files = ['propTemplates/simpleTemplate.rt', 'propTemplates/templateInScope.rt', 'propTemplates/implicitTemplate.rt', 'propTemplates/twoTemplates.rt'];
+ const files = [
+ 'simpleTemplate.rt',
+ 'templateInScope.rt',
+ 'implicitTemplate.rt',
+ 'twoTemplates.rt',
+ 'siblingTemplates.rt'
+ ].map(file => path.join('propTemplates', file));
testFiles(t, files, options);
});