Skip to content

Commit

Permalink
Introduced proxy class for the parser to bridge new/old parsing worlds
Browse files Browse the repository at this point in the history
  • Loading branch information
hugithordarson committed Oct 17, 2024
1 parent 2168295 commit 02892cc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import ng.appserver.templating.NGDeclarationFormatException;
import ng.appserver.templating.NGHTMLFormatException;
import ng.appserver.templating.NGTemplateParser;
import ng.appserver.templating.NGTemplateParserProxy;

/**
* Stores information about the structure of the component.
Expand Down Expand Up @@ -213,7 +214,7 @@ private NGElement _loadTemplate() {
return NO_ELEMENT;
}

return new NGTemplateParser( htmlTemplateStringOptional.get(), wodStringOptional.orElse( "" ) ).parse();
return new NGTemplateParserProxy( htmlTemplateStringOptional.get(), wodStringOptional.orElse( "" ) ).parse();
}
catch( NGDeclarationFormatException | NGHTMLFormatException e ) {
throw new RuntimeException( e );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package ng.appserver.templating;

import java.util.Objects;

import ng.appserver.NGElement;

/**
* Serves as a bridge between the "new and old world" for template parsing
*/

public class NGTemplateParserProxy {

private final String _htmlString;
private final String _wodString;

public NGTemplateParserProxy( String htmlString, String wodString ) {
Objects.requireNonNull( htmlString );
Objects.requireNonNull( wodString );

_htmlString = htmlString;
_wodString = wodString;
}

public NGElement parse() throws NGDeclarationFormatException, NGHTMLFormatException {
return new NGTemplateParser( _htmlString, _wodString ).parse();
}
}

0 comments on commit 02892cc

Please sign in to comment.