private void processMacro(final String macroName, final StringBuilder rawTagData) {
        final LmlTagProvider tagProvider = syntax.getMacroTagProvider(macroName);
        if (tagProvider == null) {
            throwError("No macro tag provider found for name: " + macroName);
        }
        final LmlTag macroTag = tagProvider.create(this, currentParentTag, rawTagData);
        Strings.clearBuilder(rawTagData);
        if (macroTag.isChild()) { // Immediately closing the tag, since it's a child.
            macroTag.closeTag();
            return;
        }
        int sameNameNestedMacrosAmount = 1; // We start with our own macro, hence 1.
        final StringBuilder helperBuilder = new StringBuilder();
        while (templateReader.hasNextCharacter()) {
            final char macroCharacter = templateReader.nextCharacter();
            if (macroCharacter == syntax.getTagOpening() && templateReader.hasNextCharacter()) {
                // Another tag was opened. This might be macro's end or a nested macro - we need to handle both.
                final char nextMacroCharacter = templateReader.peekCharacter();
                if (nextMacroCharacter == syntax.getClosedTagMarker()) {
                    // A tag is being closed. We need to investigate if this is our tag.
                    final int sameMacroTag = isSameMacroTagName(macroTag, helperBuilder);
                    if (sameMacroTag > -1 && --sameNameNestedMacrosAmount == 0) {
                        // We're done. All nested macros with the same name are parsed.
                        burnCharacters(sameMacroTag);
                        break;
                    }
                } else if (nextMacroCharacter == syntax.getMacroMarker()) {
                    // A macro is being open. We need to investigate if it has the same tag name.
                    if (isSameMacroTagName(macroTag, helperBuilder) > -1) {
                        sameNameNestedMacrosAmount++;
                    }
                }
            }
            // No macro tag is currently being open or the opening is irrelevant. Appending character.
            rawTagData.append(macroCharacter);
        }
        if (sameNameNestedMacrosAmount > 0) {
            throwError("Macro tag not closed: " + macroTag.getTagName());
        }
        if (Strings.isNotEmpty(rawTagData)) {
            macroTag.handleDataBetweenTags(rawTagData);
        }
        macroTag.closeTag();
    }
private void processMacro ( final String macroName , final StringBuilder rawTagData ) { final LmlTagProvider tagProvider = syntax . getMacroTagProvider ( macroName ) ; if ( tagProvider == null ) { throwError ( "No macro tag provider found for name: " + macroName ) ; } final LmlTag macroTag = tagProvider . create ( this , currentParentTag , rawTagData ) ; Strings . clearBuilder ( rawTagData ) ; if ( macroTag . isChild ( ) ) { macroTag . closeTag ( ) ; return ; } int sameNameNestedMacrosAmount = 1 ; final StringBuilder helperBuilder = new StringBuilder ( ) ; while ( templateReader . hasNextCharacter ( ) ) { final char macroCharacter = templateReader . nextCharacter ( ) ; if ( macroCharacter == syntax . getTagOpening ( ) && templateReader . hasNextCharacter ( ) ) { final char nextMacroCharacter = templateReader . peekCharacter ( ) ; if ( nextMacroCharacter == syntax . getClosedTagMarker ( ) ) { final int sameMacroTag = isSameMacroTagName ( macroTag , helperBuilder ) ; if ( sameMacroTag > - 1 && -- sameNameNestedMacrosAmount == 0 ) { burnCharacters ( sameMacroTag ) ; break ; } } else if ( nextMacroCharacter == syntax . getMacroMarker ( ) ) { if ( isSameMacroTagName ( macroTag , helperBuilder ) > - 1 ) { sameNameNestedMacrosAmount ++ ; } } } rawTagData . append ( macroCharacter ) ; } if ( sameNameNestedMacrosAmount > 0 ) { throwError ( "Macro tag not closed: " + macroTag . getTagName ( ) ) ; } if ( Strings . isNotEmpty ( rawTagData ) ) { macroTag . handleDataBetweenTags ( rawTagData ) ; } macroTag . closeTag ( ) ; }
@param macroName name of the macro tag to be parsed.
@param rawTagData raw data of the macro tag. Will be used to append data between macro tags. It will be modified,
but should be cleared manually after calling this method.