summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2006-08-23 18:49:20 (EDT)
committerpelder2006-08-23 18:49:20 (EDT)
commite2896a50c80f016295cad63dadb0a1a5ff50183d (patch)
treee59b57209c83a7173bada758bddf166a5f950492
parentb3129cd0fbfa7a43d713703c840b4c831cd15ac1 (diff)
downloadorg.eclipse.jet-e2896a50c80f016295cad63dadb0a1a5ff50183d.zip
org.eclipse.jet-e2896a50c80f016295cad63dadb0a1a5ff50183d.tar.gz
org.eclipse.jet-e2896a50c80f016295cad63dadb0a1a5ff50183d.tar.bz2
[154933] Add 'super' attribute to <c:include> tag.
-rw-r--r--doc/org.eclipse.jet.doc/references/taglibs/controlTags/includeTag.html6
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/control/IncludeTag.java5
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/transform/TransformContextExtender.java19
3 files changed, 27 insertions, 3 deletions
diff --git a/doc/org.eclipse.jet.doc/references/taglibs/controlTags/includeTag.html b/doc/org.eclipse.jet.doc/references/taglibs/controlTags/includeTag.html
index 6231439..27117ac 100644
--- a/doc/org.eclipse.jet.doc/references/taglibs/controlTags/includeTag.html
+++ b/doc/org.eclipse.jet.doc/references/taglibs/controlTags/includeTag.html
@@ -33,7 +33,7 @@
<TR>
<TD width="10%">full tag</TD>
<TD><SPAN style="font-family: monospace">
- &lt;c:include template=&quot;<I>value</I>&quot; restoreNames=&quot;<I>value</I>&quot; passVariables=&quot;<I>value</I>&quot;/&gt;<br>
+ &lt;c:include template=&quot;<I>value</I>&quot; restoreNames=&quot;<I>value</I>&quot; passVariables=&quot;<I>value</I>&quot; super=&quot;<I>value</I>&quot;/&gt;<br>
</SPAN></TD>
</TR>
</TBODY>
@@ -65,6 +65,10 @@
<TD width="10%">passVariables</TD>
<TD><BR> A comma separated list of variable names (without the $ sign). Mutually exclusive with 'restoreNames'.<BR> </TD>
</TR>
+ <TR>
+ <TD width="10%">super</TD>
+ <TD><BR> If set to 'true', the template loader attempts to load directly from the overriden transformation (as specified by the 'override' tag or by the 'overrides' attribute of the 'transform' element of the 'org.eclipse.jet.transform' extension in the transforms plugin.xml). If no 'super' template can be found, an error occurs. The default is 'false', indicating normal template loading.<BR> </TD>
+ </TR>
</TBODY>
</TABLE>
<HR>
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/control/IncludeTag.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/control/IncludeTag.java
index 114e8cd..918a611 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/control/IncludeTag.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/control/IncludeTag.java
@@ -52,6 +52,9 @@ public class IncludeTag extends AbstractEmptyTag
String template = getAttribute("template"); //$NON-NLS-1$
String restoreNames = getAttribute("restoreNames"); //$NON-NLS-1$
String passVariables = getAttribute("passVariables"); //$NON-NLS-1$
+
+ String useSuperStr = getAttribute("super"); //$NON-NLS-1$
+ boolean useSuper = useSuperStr != null && Boolean.valueOf(useSuperStr).booleanValue();
if(restoreNames != null && passVariables != null)
{
@@ -73,7 +76,7 @@ public class IncludeTag extends AbstractEmptyTag
try
{
TransformContextExtender tce = new TransformContextExtender(context);
- tce.execute(template, out);
+ tce.execute(template, useSuper, out);
}
finally
{
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/transform/TransformContextExtender.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/transform/TransformContextExtender.java
index 3b425ea..1dacebb 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/transform/TransformContextExtender.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/transform/TransformContextExtender.java
@@ -116,11 +116,27 @@ public class TransformContextExtender extends AbstractContextExtender
*/
public void execute(String templatePath, JET2Writer writer) throws JET2TagException
{
+ execute(templatePath, false, writer);
+ }
+
+ /**
+ * Execute the named template, writing all template output to the passed writer.
+ * @param templatePath the project relative path of the template to load
+ * @param useSuper if true, attempt to load the template from override transformation, if it exists
+ * @param writer the writer to which the template output will be written
+ * @throws JET2TagException if an execution error occurs or the template cannot be found
+ */
+ public void execute(String templatePath, boolean useSuper, JET2Writer writer) throws JET2TagException
+ {
getData().templateStack.push(templatePath);
getContext().setTemplatePath(getTemplatePath());
try
{
- JET2Template template = getData().loader.getTemplate(templatePath);
+ JET2TemplateLoader templateLoader = getData().loader;
+ if(useSuper) {
+ templateLoader = templateLoader instanceof JET2TemplateLoaderExtension ? ((JET2TemplateLoaderExtension)templateLoader).getDelegateLoader() : null;
+ }
+ JET2Template template = templateLoader != null ? templateLoader.getTemplate(templatePath) : null;
if (template == null)
{
@@ -134,6 +150,7 @@ public class TransformContextExtender extends AbstractContextExtender
getData().templateStack.pop();
getContext().setTemplatePath(getTemplatePath());
}
+
}
public JET2TemplateLoader getLoader()