/**
* @author Candy
* @since 16/1/13.
*/
@Component
public class Cmsdialect extends Abstractdialect {
@Override
Public String Getprefix () {
return "CRM";
}
@Override
Public set<iprocessor> getprocessors () {
Final set<iprocessor> processors = new hashset<> ();
Processors.add (New Fragmentelementprocessor ());
return processors;
}
}
@Component
public class Fragmentelementprocessor extends Abstractmarkupsubstitutionelementprocessor {
Public Fragmentelementprocessor () {
Super ("Fragment");
}
@Override
Protected list<node> getmarkupsubstitutes (Arguments Arguments, Element Element) {
Final ApplicationContext Appctx = ((Springwebcontext) Arguments.getcontext ()). Getapplicationcontext ();
Final String Path = element.getattributevalue ("path");
Final Fragmentmanager Fragmentmanager =appctx.getbean (fragmentmanager.class);
Final String content = fragmentmanager.findreleasedcontent (path);
Final element container = new Element ("div");
Final text text = new text (content);
Container.addchild (text);
/*
* The abstract Iattrprocessor implementation we are using defines
* That a list of nodes'll be returned, and that these nodes
* would substitute the tag we are processing.
*/
Final list<node> nodes = new arraylist<> ();
Nodes.Add (container);
return nodes;
}
@Override
public int getprecedence () {
return 1000;
}
}
Use of custom labels
<! DOCTYPE html>
<crm:fragment path= "/fragment.php"/>
Website link Address: http://www.thymeleaf.org/doc/tutorials/2.1/extendingthymeleaf.html#attribute-processors
Thymeleaf Custom Labels