private void injectCloseTag ( HtmlOpenTagNode optionalOpenTag , HtmlTagNode destinationTag , IdGenerator idGenerator ) { StandaloneNode openTagCopy = optionalOpenTag . getTagName ( ) . getNode ( ) . copy ( new CopyState ( ) ) ; HtmlCloseTagNode syntheticClose = new HtmlCloseTagNode ( idGenerator . genId ( ) , openTagCopy , optionalOpenTag . getSourceLocation ( ) , TagExistence . SYNTHETIC ) ; // If destination is null, then insert at the end of the template. if ( destinationTag == null ) { int i = optionalOpenTag . getParent ( ) . getChildren ( ) . size ( ) ; optionalOpenTag . getParent ( ) . addChild ( i , syntheticClose ) ; } else { // This inserts the synthetic close tag right before the open tag. ParentSoyNode < StandaloneNode > openTagParent = destinationTag . getParent ( ) ; int i = openTagParent . getChildIndex ( destinationTag ) ; openTagParent . addChild ( i , syntheticClose ) ; } annotationMap . put ( optionalOpenTag , Optional . of ( syntheticClose ) ) ; annotationMap . put ( syntheticClose , Optional . of ( optionalOpenTag ) ) ; }
Rebalances HTML tags when necessary .