If you know Facelets, it isn't something like a simple JSP include or angular ng-include
where the template itself defines what contents should be in the template.
In Facelets, the template only defines which parts of it are dynamic or replaceable and the view can use it and tell what contents should be in those replaceable parts of the template. In Facelets, a single page can feed all the replaceable parts of the template in just one file.
Facelets example:
Template: template.xhtml:
<h:body>
<div>
<ui:insert name="main_section">Main Section</ui:insert>
</div>
<div>
<ui:insert name="section">Section</ui:insert>
</div>
<div>
<ui:insert name="sub_section">Sub Section</ui:insert>
</div>
</h:body>
View: somepage.xhtml
<ui:composition template="./template.xhtml">
<ui:define name="main_section">
Welcome to main section which is defined by this somepage.xhtml
</ui:define>
<ui:define name="section">
.. section as defined by this somepage.xhtml
</ui:define>
<ui:define name="sub_section">
.. subsection as defined by this somepage.xhtml
</ui:define>
</ui:composition>
This is unlike the regular include template in which the template does not allow the pages to define the contents of the template other than where exactly it is used in the template.
ngInclude Example
View: main.html
<div>
<ng-include src="./somepage_main_section.html"></ng-include>
<ng-include src="./somepage_section.html"></ng-include>
<ng-include src="./somepage_sub_section.html"></ng-include>
<div>
Problem
In ng-include
, there's no way somepage.html
can define or feed other replaceable parts of the template. It has to separate all the parts of the template into multiple files and hardcode it.
I know that Facelets works on the server side while ng-include works on the browser side but what's important is the concept. As much as possible, we would want this same concept applied in AngularJS. We're using Play Framework by the way which means we can't use Facelets.