Ah, ok, in the case of Database-loaded templates with Seam Render, that&#39;s the reason why I made the <i>TemplateResolver </i>class in the first place. The template path in render is actually an extensible lookup scheme.<br>
<br><b>So:</b><br><br><div style="margin-left: 40px;">@include{&quot;db:users/1/order/12/template&quot;}@end{}</div><br><b>Could be interpreted by a TemplateResolver which would perform the DB lookup and provide the template.</b><br>
<br>You&#39;d need a <i>DatabaseTemplateResolver </i>and <i>DatabaseTemplateResource</i>. Once that&#39;s done, and you define your path scheme, you&#39;re all set! The resolver will handle lookups automatically! Caching templates so that you don&#39;t hammer the database might be a few extra steps.<br>
<b><br>First, you register the resolver in the services file:</b><br><br><div style="margin-left: 40px;">/META-INF/services/org.jboss.seam.render.spi.TemplateResolver<br>com.example.myapp.DatabaseTemplateResolver<br></div>
<br><b>Then it&#39;s then as simple as:</b><br><br><div style="margin-left: 40px;">@Inject TemplateCompiler compiler;<br></div><div style="margin-left: 40px;">TemplateResource&lt;?&gt; template =  compiler.compile(&quot;db:nameOfTemplate/id12/param2/&quot;);<br>
<br>template.render(); //already integrated with CDI internally :)<br><br>// or the template lookup can be as simple as a name or id, but I still recommend the use a &quot;prefix:&quot;<br>// &quot;db:passwordRecovery&quot;<br>
<br></div><b>Templates of any resource type can reference templates of another type:<br></b><div style="margin-left: 40px;"><br>TemplateResource&lt;?&gt; template =  compiler.compile(&quot;db:nameOfTemplate/id12/param2/&quot;);<br>
<br>// the template above contains an include statement to a classpath template, which in turn includes another database template.<br><br>@include{&quot;/org/jboss/seam/mail/basicHtmlTemplate.render&quot;} @end{}<br>----&gt; @include{&quot;db:templateThatChangesFrequently&quot;} @end{}<br>
<br>// This from within your database template, will perform a classpath or filesystem lookup (using the included resolvers.) So you can do cool things like cross-resolver referencing of templates.<br></div><br>~Lincoln<br>
<br><br><br><div class="gmail_quote">On Mon, Mar 7, 2011 at 3:57 PM, Cody Lerum <span dir="ltr">&lt;<a href="mailto:cody.lerum@gmail.com">cody.lerum@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
You definitely want the ability to send in the template content via<br>
inputstream however like I do with mail template.<br>
<br>
I for example store my templates in the database.<br>
<font color="#888888"><br>
-C<br>
</font><div><div></div><div class="h5"><br>
On Mon, Mar 7, 2011 at 1:19 PM, Lincoln Baxter, III<br>
&lt;<a href="mailto:lincolnbaxter@gmail.com">lincolnbaxter@gmail.com</a>&gt; wrote:<br>
&gt; :)<br>
&gt;<br>
&gt; BTW. RenderTemplate would look something like this... since Render has its<br>
&gt; own TemplateResolver SPI, it wouldn&#39;t be very complicated from Seam Mail&#39;s<br>
&gt; end.<br>
&gt;<br>
&gt; I don&#39;t think there&#39;s a real way that the MailTemplate interface would go<br>
&gt; with Render, unless an additional render TemplateResource implementation<br>
&gt; were provided to wrap it internally here. The only issue is that Render<br>
&gt; attempts to resolve relative paths in templates, so using MailTemplate<br>
&gt; doesn&#39;t really make sense here. Really render already implements a good deal<br>
&gt; of what you are having to do in mail by trying to abstract the template<br>
&gt; input stream from the templating system itself... I believe you&#39;ll have a<br>
&gt; similar problem with Freemarker (or even with velocity if folks use any<br>
&gt; @Include(&quot;templateName.path&quot;) declarations.<br>
&gt;<br>
&gt; Thoughts?<br>
&gt;<br>
&gt; /*<br>
&gt;  * JBoss, Home of Professional Open Source<br>
&gt;  * Copyright 2011, Red Hat, Inc., and individual contributors<br>
&gt;  * by the @authors tag. See the copyright.txt in the distribution for a<br>
&gt;  * full listing of individual contributors.<br>
&gt;  *<br>
&gt;  * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);<br>
&gt;  * you may not use this file except in compliance with the License.<br>
&gt;  * You may obtain a copy of the License at<br>
&gt;  * <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">http://www.apache.org/licenses/LICENSE-2.0</a><br>
&gt;  * Unless required by applicable law or agreed to in writing, software<br>
&gt;  * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,<br>
&gt;  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br>
&gt;  * See the License for the specific language governing permissions and<br>
&gt;  * limitations under the License.<br>
&gt;  */<br>
&gt;<br>
&gt; package org.jboss.seam.mail.templating.render;<br>
&gt;<br>
&gt; import java.io.InputStream;<br>
&gt; import java.util.HashMap;<br>
&gt; import java.util.Map;<br>
&gt;<br>
&gt; import org.jboss.seam.mail.templating.MailTemplate;<br>
&gt; import org.jboss.seam.mail.templating.TemplateImpl;<br>
&gt; import org.jboss.seam.render.TemplateCompiler;<br>
&gt; import org.jboss.seam.render.spi.TemplateResolver;<br>
&gt; import org.jboss.seam.render.spi.TemplateResource;<br>
&gt; import org.jboss.seam.render.template.CompiledTemplateResource;<br>
&gt;<br>
&gt; /**<br>
&gt;  * @author &lt;a href=&quot;mailto:<a href="mailto:lincolnbaxter@gmail.com">lincolnbaxter@gmail.com</a>&quot;&gt;Lincoln Baxter, III&lt;/a&gt;<br>
&gt;  */<br>
&gt; public class RenderTemplate implements TemplateImpl<br>
&gt; {<br>
&gt;    private final CompiledTemplateResource template;<br>
&gt;<br>
&gt;    public RenderTemplate(TemplateCompiler compiler, final MailTemplate<br>
&gt; template)<br>
&gt;    {<br>
&gt;       // not sure this integration really makes sense. Render should<br>
&gt; probably be responsible only for delivering a java.lang.String as output.<br>
&gt;       TemplateResource&lt;InputStream&gt; resource = new<br>
&gt; TemplateResource&lt;InputStream&gt;()<br>
&gt;       {<br>
&gt;          @Override<br>
&gt;          public String getPath()<br>
&gt;          {<br>
&gt;             return template.getTemplateName();<br>
&gt;          }<br>
&gt;<br>
&gt;          @Override<br>
&gt;          public InputStream getInputStream()<br>
&gt;          {<br>
&gt;             return template.getInputStream();<br>
&gt;          }<br>
&gt;<br>
&gt;          @Override<br>
&gt;          public long getLastModified()<br>
&gt;          {<br>
&gt;             return 0;<br>
&gt;          }<br>
&gt;<br>
&gt;          @Override<br>
&gt;          public InputStream getUnderlyingResource()<br>
&gt;          {<br>
&gt;             return getInputStream();<br>
&gt;          }<br>
&gt;<br>
&gt;          @Override<br>
&gt;          public TemplateResolver&lt;InputStream&gt; getResolvedBy()<br>
&gt;          {<br>
&gt;             return new TemplateResolver&lt;InputStream&gt;()<br>
&gt;             {<br>
&gt;                @Override<br>
&gt;                public TemplateResource&lt;InputStream&gt; resolve(String target)<br>
&gt;                {<br>
&gt;                   // render will throw an error if this is reached<br>
&gt;                   return null;<br>
&gt;                }<br>
&gt;<br>
&gt;                @Override<br>
&gt;                public TemplateResource&lt;InputStream&gt;<br>
&gt; resolveRelative(TemplateResource&lt;InputStream&gt; origin, String target)<br>
&gt;                {<br>
&gt;                   // render will throw an error if this is reached<br>
&gt;                   return null;<br>
&gt;                }<br>
&gt;             };<br>
&gt;          }<br>
&gt;       };<br>
&gt;<br>
&gt;       this.template = compiler.compile(resource);<br>
&gt;    }<br>
&gt;<br>
&gt;    public RenderTemplate(TemplateCompiler compiler, String path)<br>
&gt;    {<br>
&gt;       template = compiler.compile(path);<br>
&gt;    }<br>
&gt;<br>
&gt;    public RenderTemplate(TemplateCompiler compiler, TemplateResource&lt;?&gt;<br>
&gt; resource)<br>
&gt;    {<br>
&gt;       template = compiler.compile(resource);<br>
&gt;    }<br>
&gt;<br>
&gt;    public RenderTemplate(CompiledTemplateResource template)<br>
&gt;    {<br>
&gt;       this.template = template;<br>
&gt;    }<br>
&gt;<br>
&gt;    @Override<br>
&gt;    public String merge(Map&lt;String, Object&gt; context)<br>
&gt;    {<br>
&gt;       Map&lt;Object, Object&gt; map = new HashMap&lt;Object, Object&gt;();<br>
&gt;       map.putAll(context);<br>
&gt;<br>
&gt;       String rendered = template.render(map);<br>
&gt;       return rendered;<br>
&gt;    }<br>
&gt; }<br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Lincoln Baxter, III<br><a href="http://ocpsoft.com">http://ocpsoft.com</a><br><a href="http://scrumshark.com">http://scrumshark.com</a><br>&quot;Keep it Simple&quot;<br>