Rich Hickey wrote:
> 
> 
> On Dec 3, 1:04 pm, Jeff Rose <[EMAIL PROTECTED]> wrote:
>> I've just pushed a template library for Clojure up onto github for
>> public use.  You can find it here:
>>
>> http://github.com/rosejn/clj-libs/tree/master
>>
>> This library is based loosely on erb from Ruby, which is the only other
>> template system I've used, and it allows you to insert Clojure
>> scriptlets inside a text document.  Following is a short example of how
>> it currently works.  Any thoughts, suggestions or feedback are welcome.
>>   I plan on making it easier to instantiate pages by passing a hash, or
>> maybe a sequence of hashes, which will be successively bound for you.
>> I'll probably add some configuration options for handling whitespace and
>> trimming newlines too.  Any other ideas or patches welcome.
>>
> 
> Neat! One thing I recommend is that you consider taking a functional
> approach to templates - it would be much more in line with Clojure.
> Two examples of a more functional approach are:
> 
> StringTemplate
> http://www.stringtemplate.org/
> 
> Google XML Pages
> http://code.google.com/p/gxp/
> 
> Rich

Ok, I can see the benefits of a functional style template.  Do you think 
the important aspect of this is whether you use a push or a pull model 
for populating forms with data?  In a functional style you would pass 
all the necessary values to a function, which would then populate the 
form and return a result. I don't like the idea of having to use XML or 
some mini-language to do variable replacement, if statements, and 
iteration over collections though.  If I make the template library a 
push model where you send it the values, but you just use Clojure code 
to determine how they get used, does that still fit the bill?

As for the javascript template engines, I think that kind of solution 
might be great for a websites, but a template engine like this is useful 
for many applications besides filling in html pages, so I'd still like 
to have a generic template mechanism from within Clojure.  From the 
above, I think StringTemplate has some interesting ideas.  I'm going to 
look into supporting recursive template application and include mechanisms.

-Jeff

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to