Solved!
public class CnmCustomDialect extends AbstractProcessorDialect {
public CnmCustomDialect() {
super("CNM Tags", "cnmtags", StandardDialect.PROCESSOR_PRECEDENCE);
}
@Override
public Set<IProcessor> getProcessors(String dialectPrefix) {
Set<IProcessor> processors = new HashSet<>();
processors.add(new TableBuilderElementTagProcessor(getPrefix()));
return processors;
}
}
@Bean
public SpringTemplateEngine templateEngine(ITemplateResolver templateResolver, SpringSecurityDialect sec) {
final SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.addDialect(new CnmCustomDialect());
return templateEngine;
}
3.Implement custom AbstractElementTagProcessor
-Use doProcess() method to get inputs from HTML by this tag variable and bind into the handler variable
-String modelType = tag.getAttributeValue("tt");
-Content=”Add html your content as required”
-structureHandler.replaceWith(content, false);
public class TableBuilderElementTagProcessor extends AbstractElementTagProcessor {
private ApplicationContext applicationContext;
public TableBuilderElementTagProcessor(String dialectPrefix) {
super(TemplateMode.HTML, dialectPrefix, "table", true, null, false, StandardDialect.PROCESSOR_PRECEDENCE);
}
@Override
protected void doProcess(ITemplateContext context, IProcessableElementTag tag,IElementTagStructureHandler structureHandler) {
applicationContext = SpringContextUtils.getApplicationContext(context);
String content=""; structureHandler.replaceWith(content, false);}}
Thanks