Hi Tim,

Rather than using ERXSimpleTemplateParser which is quite old, doesn’t handle 
repetitions, … I would take a look at Mustache - http://mustache.github.io

I use this library for example: https://github.com/samskivert/jmustache

Or WOComponent as said Samuel.

But Mustache syntax is simple to understand.

If you need to read some code, you can take a look here:
https://github.com/Sophiacom/ERCommunication/blob/master/framework/ERCommunication/Sources/er/communication/foundation/ERAbstractMessageProcessor.java

Look at the methods getTextContent() and parseTemplate() (consider a media as 
an email for example).

Philippe

On 9 oct. 2015, at 22:09, Samuel Pelletier <[email protected]> wrote:

> Hi,
> 
> You can use the WOComponent engine with html template stored elsewhere (in 
> filesystem or database). I've done that many years ago in an Objective C WO 
> app... This allows the uses of conditional, repeats and all other great wo 
> components. 
> 
> If you use inline bindings in the HTML for your template, you have a single 
> file to manage.
> 
> You need to create at least one custom WOComponent that will contains the 
> logic to load the proper HTML and offer the methods expected by your 
> templates.
> 
> This custom WOComponent should disable the template caching in it's 
> constructor with setCachingEnabled(false).
> 
> The method template() needs to be overidden to provide the template 
> dynamically from your file or database. To parse the HTML to a WOElement, you 
> need this method: WOComponent.templateWithHTMLString(...) that returns 
> WOElement.
> 
> If simple markup replacement is enough, ERXSimpleTemplateParser will do the 
> job.
> 
> Samuel
> 
> 
>> Le 2015-10-09 à 14:23, T Worman <[email protected]> a écrit :
>> 
>> I love WOComponent as a template engine - but I want my templates to live on 
>> the file system, not part of an app/framework bundle. This way if quick 
>> edits need to be made I can simply access them (or even someone else in a 
>> support role), make minor changes and have those changes impact the runtime 
>> immediately without requiring new builds or app uploads. Also, I can house 
>> them at a location on the filesystem that does not require “WO” knowledge.
>> 
>> Tim
>> 
>>> On Oct 9, 2015, at 9:03 AM, CHRISTOPH WICK | i4innovation GmbH, Bonn 
>>> <[email protected]> wrote:
>>> 
>>> Hi Tim,
>>> 
>>> if you're are using Wonder, it seems obvious to me to use WOComponent as a 
>>> template engine.
>>> 
>>> 1. define your component as you do with normal wocomponents
>>> 
>>> 2. Instantiate like this:
>>> 
>>> YourMailComponent mailComponent = (YourMailComponent) 
>>> ERMailUtils.instantiatePage(your.app. YourMailComponent.class.getName(), 
>>> null);
>>> mailComponent.setBinding1(binding1Value);
>>> mailComponent.setBinding2(binding2Value);
>>> String htmlOfYourMailComponent = 
>>> mailComponent.generateResponse().contentString()
>>> 
>>> C.U.CW
>>> --
>>> The three great virtues of a programmer are Laziness, Impatience and 
>>> Hubris. (Randal Schwartz)
>>> 
>>>> On 09.10.2015, at 17:39, T Worman <[email protected]> wrote:
>>>> 
>>>> Reaching out to the list to see what my fellow abandonees prefer for 
>>>> templating. My needs are pretty simple - I’m just looking to use templates 
>>>> to compose emails. I have far too many email methods where the bodies of 
>>>> the emails are completely composed in code and I’d really like to move 
>>>> that out to some template engine.
>>>> 
>>>> So, the question is, what template engine do you prefer for this kind of 
>>>> work? Obviously, we’ve already got velocity producing our EO .java files - 
>>>> and I’m sure that’s workable. Any strong preferences out there?
>>>> 
>>>> I really like StringTemplate (http://www.stringtemplate.org). A feature I 
>>>> liked was the ability to pass an object to the template and the template 
>>>> could contain “keypaths” to attributes of the object - very much like we 
>>>> expect from the WO template engine. However, it would not work with 
>>>> accessors that do not use the get* convention - which I haven’t. I could 
>>>> convert but not sure it is worth it.
>>>> 
>>>> Tim
>>>> _______________________________________________
>>>> Do not post admin requests to the list. They will be ignored.
>>>> Webobjects-dev mailing list      ([email protected])
>>>> Help/Unsubscribe/Update your Subscription:
>>>> https://lists.apple.com/mailman/options/webobjects-dev/cw%40i4innovation.de
>>>> 
>>>> This email sent to [email protected]
>>> 
>> 
>> 
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list      ([email protected])
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com
>> 
>> This email sent to [email protected]
> 
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      ([email protected])
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/prabier%40icloud.com
> 
> This email sent to [email protected]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to