use of com.axellience.vuegwt.processors.component.template.parser.result.TemplateParserResult in project vue-gwt by Axellience.
the class TemplateParser method parseHtmlTemplate.
/**
* Parse a given HTML template and return the a result object containing the expressions
* and a transformed HTML.
* @param htmlTemplate The HTML template to process, as a String
* @param context Context of the Component we are currently processing
* @param messager Used to report errors in template during Annotation Processing
* @return A {@link TemplateParserResult} containing the processed template and expressions
*/
public TemplateParserResult parseHtmlTemplate(String htmlTemplate, TemplateParserContext context, Messager messager) {
this.context = context;
this.logger = new TemplateParserLogger(context, messager);
initJerichoConfig(this.logger);
Source source = new Source(htmlTemplate);
outputDocument = new OutputDocument(source);
result = new TemplateParserResult(context);
processImports(source);
source.getChildElements().forEach(this::processElement);
result.setProcessedTemplate(outputDocument.toString());
return result;
}
use of com.axellience.vuegwt.processors.component.template.parser.result.TemplateParserResult in project vue-gwt by Axellience.
the class ComponentTemplateProcessor method processComponentTemplate.
public void processComponentTemplate(TypeElement componentTypeElement, Builder componentJsTypeBuilder) {
ClassName componentTypeName = ClassName.get(componentTypeElement);
Optional<String> optionalTemplateContent = getTemplateContent(componentTypeName, componentTypeElement);
if (!optionalTemplateContent.isPresent())
return;
LocalComponents localComponents = new LocalComponents();
findLocalComponentsForComponent(localComponents, componentTypeElement);
// Initialize the template parser context based on the VueComponent type element
TemplateParserContext templateParserContext = new TemplateParserContext(componentTypeElement, localComponents);
registerFieldsAndMethodsInContext(templateParserContext, componentTypeElement, new HashSet<>(), new HashSet<>());
// Parse the template
TemplateParserResult templateParserResult = new TemplateParser().parseHtmlTemplate(optionalTemplateContent.get(), templateParserContext, messager);
// Add expressions from the template to JsType and compile template
TemplateMethodsBuilder templateMethodsBuilder = new TemplateMethodsBuilder();
templateMethodsBuilder.addTemplateMethodsToComponentJsType(componentJsTypeBuilder, templateParserResult);
}
Aggregations