Mueas project, the Web front end uses thymeleaf as the presentation layer. This view parser, personally feel very good. Simple and performance is better! Personal feel than JSP and freemarker, such as simple and easy to use!
Today simply record the use of fragment, this class is the JSP tag, but it is very simple. In the HTML file, you can wrap up the block of elements that you think might appear in multiple places with fragment!
For example:
1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 ...5 </Head>6 <Body>7 <Div th:fragment= "Footer"> 8 ©Footer9 </Div>Ten </Body> One </HTML>
In the place of use, and then use the include tag to introduce it!
For example:
1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <!--/* Each token would be replaced to their respective titles in the resulting page. * / -5 <titleLayout:title-pattern= "$DECORATOR _title-$CONTENT _title">Task List</title>6 ...7 </Head>8 <Body>9 <!--/ * Standard layout can is mixed with layout dialect * / -Ten <DivTh:replace= "Fragments/header:: Header"> One ... A </Div> - <Divclass= "Container"> - <Divlayout:fragment= "Content"> the <!-- ============================================================================ - - <!--This content was only used for static prototyping purposes (natural templates) - - <!--and is therefore entirely optional, as this markup fragment would be included - - <!--From ' fragments/header.html ' at runtime. - + <!-- ============================================================================ - - <H1>Static content for prototyping purposes only</H1> + <P> A Lorem ipsum dolor sit amet, consectetur adipiscing elit. at praesent scelerisque neque neque, ac elementum quam dignissim interdum. - phasellus et placerat elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. - praesent scelerisque neque neque, ac elementum quam dignissim interdum. - phasellus et placerat elit. - </P> - </Div> in <DivTh:replace= "Fragments/footer:: Footer">©The Static Templates</Div> - </Div> to </Body> + </HTML>
Note: Th:fragment defined fragments, where needed, can be brought in with Th:include or Th:replace!
Also, all fragment can be written in a file or can exist separately. Can be part of an HTML file. As long as you need to, bring the Th:fragment label to define it, and make it a fragment. It is important to note that the path of the file where the fragment is located, to separate the path with "/", the root path is the path where templates is located.
Like what:
1 <Body>2 <Divclass= "Container">3 <DivTh:include= "exam/special/geeker/geeker:: Geeker-base-header"></Div>4 <Divclass= "Geeker-content">5 <DivTh:include= "Exam/special/geeker/geeker::geeker-base-left"></Div> 6 <Divclass= "Geeker-main">7 </Div>8 <Divclass= "Geeker-right">9 </Div>Ten </Div> One </Div> A </Body>
Isn't it very easy to use? I feel very good!
The fragment of Thymeleaf