public int parseStartLoop( String content, DirectivesStack directives, int startOfStartListDirectiveIndex )
    {
        // contentWichStartsWithList='[#list developers as d]yyy'
        String contentWhichStartsWithList = content.substring( startOfStartListDirectiveIndex, content.length() );
        int endOfStartListDirectiveIndex = contentWhichStartsWithList.indexOf( ']' );
        if ( endOfStartListDirectiveIndex == -1 )
        {
            // [#list not closed with ']'
            return 0;
        }
        // startLoopDirective='[#list developers as d]'
        String startLoopDirective = contentWhichStartsWithList.substring( 0, endOfStartListDirectiveIndex + 1 );
        // insideLoop='developers as d]'
        String insideLoop = startLoopDirective.substring( START_LIST_DIRECTIVE.length(), startLoopDirective.length() );
        int indexBeforeAs = insideLoop.indexOf( " " );
        if ( indexBeforeAs == -1 )
        {
            return 0;
        }

        // afterSequence=' as d]'
        String afterSequence = insideLoop.substring( indexBeforeAs, insideLoop.length() );
        int indexAfterAs = afterSequence.indexOf( AS_DIRECTIVE );
        if ( indexAfterAs == -1 )
        {
            return 0;
        }

        // sequence='developpers'
        String sequence = insideLoop.substring( 0, indexBeforeAs ).trim();
        if ( StringUtils.isEmpty( sequence ) )
        {
            return 0;
        }
        // afterAs='d]'
        String afterAs = afterSequence.substring( AS_DIRECTIVE.length(), afterSequence.length() );
        int endListIndex = afterAs.indexOf( ']' );
        if ( endListIndex == -1 )
        {
            return 0;
        }
        // item='d'
        String item = afterAs.substring( 0, endListIndex ).trim();
        if ( StringUtils.isEmpty( item ) )
        {
            return 0;
        }

        int nbLoop = 1;
        directives.push( new LoopDirective( directives.peekOrNull(), startLoopDirective, getEndLoopDirective( null ),
                                            sequence, item ) );

        // afterList = 'yyy'
        String afterList =
            content.substring( startOfStartListDirectiveIndex + startLoopDirective.length(), content.length() );
        nbLoop += extractListDirectiveInfo( afterList, directives );
        return nbLoop;
    }
 private int parseEndIf( String content, DirectivesStack directives, boolean dontRemoveListDirectiveInfo,
                         int startOfEndIfDirectiveIndex )
 {
     if ( !dontRemoveListDirectiveInfo && !directives.isEmpty() )
     {
         // remove the LoopDirective from the stack
         directives.pop();
     }
     // get content after the [/#if]
     String afterEndList =
         content.substring( END_IF_DIRECTIVE.length() + startOfEndIfDirectiveIndex, content.length() );
     int nbLoop = -1;
     // parse the content after the [/#if]
     nbLoop += extractListDirectiveInfo( afterEndList, directives );
     return nbLoop;
 }
 private int parseStartIf( String content, DirectivesStack directives, int startOfStartIfDirectiveIndex )
 {
     // contentWichStartsWithList='[#if d]yyy'
     String contentWhichStartsWithIf = content.substring( startOfStartIfDirectiveIndex, content.length() );
     int endOfStartIfDirectiveIndex = contentWhichStartsWithIf.indexOf( ']' );
     if ( endOfStartIfDirectiveIndex == -1 )
     {
         // [#if not closed with ']'
         return 0;
     }
     // startIfDirective='#if($d)'
     String startIfDirective = contentWhichStartsWithIf.substring( 0, endOfStartIfDirectiveIndex + 1 );
     // // contentWichStartsWithList='xxx#if($d)yyy'
     int nbIf = 1;
     directives.push( new IfDirective( directives.peekOrNull(), startIfDirective, getEndIfDirective( null ) ) );
     // afterIf = 'yyy'
     String afterIf = content.substring( startOfStartIfDirectiveIndex + startIfDirective.length(), content.length() );
     nbIf += extractListDirectiveInfo( afterIf, directives );
     return nbIf;
 }