[stringtemplate-interest] Is there way to call templates from another group without inheritance?
Florin T.PATRASCU
flop at rogers.com
Wed Sep 12 05:56:54 PDT 2007
Hi Ulf,
If your goal is to use ST for web development, I can recommend you to
have a look at our project JPublish (http://www.jpublish.org) and the
recently added String Template support.
So, to your example, with JP you can define many Repositories
(folders on disk, tables in a db, etc) where you can store individual
ST files. JP then will create for you a ST Group for every defined
Repository, pointing to the repository path.
After that, your colleagues can reuse each other's templates by
specifying the repository name and the name of the ST file they want
to use and combine them to obtain simple/complex web pages. Example:
$my_repository.( page.Path)$
For the line above, JP will use the ST rendering engine to render the
ST files but it will also execute the JP Actions associated with the
ST files (Java classes, Beanshell, Jython, JRuby or Groovy) to glue
in the logic before rendering a template or after rendering it:)
The entire JP development philosophy relies on templates and
modularity. This is why we believe ST is very appropriate for JP.
There is a ready to go JP simple project demonstrating the
StringTemplate integration. You can find it archived here: http://
jpublish.googlecode.com/files/stdemo.war.zip, in case you want to
give it a try.
I hope it helps.
V/r
-florin
On 11-Sep-07, at 08:22 , Dreyer Ulf (CR/APA3) wrote:
> Hi,
>
> I'm working on a system where the user (not necessarily an
> accomplished developer)
> can write own templates / templategroups.
> I'd like them to be able to call other templates in different
> groups without using
> inheritance.
>
> Example: user A writes a template group that generates Component
> A ( or Webpage A or whatever)
> user B writes a template group that generates
> Component B ( or Webpage A or whatever)
>
> now User C would like to write a template with the output A; B.
> Preferably by writing something like combinedTemplates :== <<
> <A.main()>; <B.main()> >>
> (Assuming "main" is the generating template in groups A and B)
>
> If I'm correct this is
>
> a) not possible if neither group A nor group B inherit from one
> another.
>
> b) possible if B inherits from A but ONLY if C inherits B and none
> of them uses
> the same names for templates.
>
> Is there an way to handle this nicely?
>
> My idea would be to mangle the names of the templates with their
> group and create a temporary group containing all templates. This
> solution will very likly turn out to be messy.
>
>
> Ulf
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20070912/3867a1bc/attachment.html
More information about the stringtemplate-interest
mailing list