'use strict';

function splitBody(body, splitterString) {
  const splitter = new RegExp(splitterString, 'g');
  const matches = body.match(splitter);
  if (matches) {
    const content = {};
    for (let i = 0; i < matches.length; i++) {
      const indexOfMatch = body.indexOf(matches[i]);
      let indexOfNextMatch = body.indexOf(matches[i + 1]);
      indexOfNextMatch = indexOfNextMatch === -1 ? undefined : indexOfNextMatch;
      content[matches[i].substring(3, matches[i].length - 3)] = body.substring(indexOfMatch + matches[i].length, indexOfNextMatch);
    }
    return content;
  }
  // No sections, just return the body as content
  return {
    content: body,
  };
}

const type = 'helper';
const name = 'bodySplitter';
function registration(register) {
  register(type, name, splitBody);
}

module.exports = registration;

@@ -294,16 +294,70 @@
     let 
+indexOfNextMatch;%0A      if (matches%5Bi + 1%5D) %7B%0A        
 indexOfN
@@ -393,24 +393,32 @@
 es%5Bi + 1%5D);%0A
+      %7D%0A
       indexO

fix so that body splitter works when the word undefined is used in the content