spec/helpers/fixture-utils.js
function createComplexTemplate ( templateLanguage, options ) {
    var t = getTemplateLanguageConstructs( templateLanguage ),

        indent = options && options.indentation || "",
        insert = options && options.insertion || "",

        lines = [
            '<!-- top-level comment (single line) -->',
            '<!--',
            '  top-level',
            '  comment',
            '  (multi-line)',
            '-->',

            t.if,
            '<p>This is a %%paragraph',
            'Some random %%text&& with different line breaks.<br><br/><br />',
            t.else,
            '<h1 class="header">This is a %%header&&</h1>    ',
            t.endIf,
            t.if,
            '</p>',
            t.endIf,

            insert,

            'Some top-level %%text&&, not wrapped in a tag.<br><br/><br />',
            '<!-- comment containing a <div> tag -->',
            "<" + "script>alert( 'foo' );</" + "script>",
            '<p class="significantWhitespaceExpected">',
            '  some text  </p>',
            '<%%tagName&& %%attrs&&>lorem ipsum</%%tagName&&>',
            '<p><h1>Invalid nesting</h1></p>',

            t.partial,

            '<dl class="%%dl_class&&">',
            '  ' + t.loop,
            '  <dt class="dtclass">%%dd_name&&</dt>',
            '  <dd class="ddclass">%%dd_content&&</dd>',
            '  ' + t.endLoop,
            '</dl>'
        ],

        innerContent = _.map( lines, function ( line ) {
            return indent + line;
        } ).join( "\n" );

    return innerContent.replace( /%%/g, t.startDelimiter ).replace( /&&/g, t.endDelimiter );
}
function createComplexTemplate ( templateLanguage, options ) {
    var t = getTemplateLanguageConstructs( templateLanguage ),

        indent = options && options.indentation || "",
        insert = options && options.insertion || "",

        lines = [
            '<!-- top-level comment (single line) -->',
            '<!--',
            '  top-level',
            '  comment',
            '  (multi-line)',
            '-->',

            t.if,
            '<p>This is a %%paragraph',
            'Some random %%text&& with different line breaks.<br><br/><br />',
            t.else,
            '<h1 class="header">This is a %%header&&</h1>    ',
            t.endIf,
            t.if,
            '</p>',
            t.endIf,

            insert,

            'Some top-level %%text&&, not wrapped in a tag.<br><br/><br />',
            '<!-- comment containing a <div> tag -->',
            "<" + "script>alert( 'foo' );</" + "script>",
            '<p class="significantWhitespaceExpected">',
            '  some text  </p>',
            '<%%tagName&& %%attrs&&>lorem ipsum</%%tagName&&>',
            '<p><h1>Invalid nesting</h1></p>',

            t.partial,

            '<dl class="%%dl_class&&">',
            '  ' + t.loop,
            '  <dt class="dtclass">%%dd_name&&</dt>',
            '  <dd class="ddclass">%%dd_content&&</dd>',
            '  ' + t.endLoop,
            '</dl>'
        ],

        innerContent = _.map( lines, function ( line ) {
            return indent + line;
        } ).join( "\n" );

    return innerContent.replace( /%%/g, t.startDelimiter ).replace( /&&/g, t.endDelimiter );
}
Creates the content of a complex template. It should contain as many pitfalls for correct processing as possible.

Features:

- has a top-level comment (single line)
- has a top-level comment (multi-line)
- has a comment containing a tag
- has numerous top-level tags
- has text at top level, not enclosed in another tag
- has tags nested in invalid ways, creating invalid HTML (<h1> inside <p>)
- has significant whitespace which must be preserved
- has template vars inside a tag itself (defining attributes)
- has a template var define the tag type
- has templating instructions (if/else)
- has a script tag inside the template, containing Javascript
- has a reference to a partial template

NB For ES6 templates, only the start and end delimiters used for a variable are supported, other constructs (if, loop,
partial) are omitted here.

@param   {string} templateLanguage          values are "Handlebars", "EJS" (EJS), "ES6"
@param   {object} [options]
@param   {string} [options.indentation=""]  a string of whitespace, e.g. "   " or "" (no indentation)
@param   {string} [options.insertion=""]    an additional string which is inserted somewhere in the middle of the
content (if left undefined, a blank line, plus insertion, appears instead)
@returns {string}