Re: #properties directive
Keats Kirsch <[email protected]> Sun, 31 Jul 2005 22:40:31 -0400
| Newsgroups | gmane.comp.java.webmacro.user |
|---|---|
| Message-ID | <[email protected]> |
Lane Sharman wrote:
> Hi Keats,
>
> Do you really want to include this in the pending 2.1 release?
I don't really care. Maybe we could include it but not enable it by
default?
> Have you considered that you now have to document 2 ways to set a
> property, #properties and #set? Will this confuse a new person to
> WebMacro? Is your #property ... a big advantage over #set
> $Object.Property = "foo"
I've found it annoying when I have to set more than a couple of
properties. Also it's cool to be able to initialize an object's state
from a properties file.
> It is certainly a nice convenience. Just not sure that its inclusion
> will improve more than its support and documentation demands will warrant.
I don't think the documentation is a big issue. I'll put up a Wiki
page. And it's not like WM requires much support these days. I'm not
wedded to this, it's just something that comes in handy for me and
someone else wanted it as well, so I put it out there.
Thanks for carrying the ball.
Keats
> -Lane
>
>
>
> Keats Kirsch wrote:
>
>> I created a new directive called Properties directive. This can be
>> handy if you want to set a bunch of properties on an object within a
>> template; essentially providing a abbreviated, readable syntax. You
>> can also combine it with the #include directive for processing a
>> properties file. (Just be careful of comments: use "##" or "# " to
>> keep them from confusing the parser.)
>>
>> I'm attaching the source and I will commit it to the core if folks
>> agree it is worthy.
>>
>> Here's some test WMScript that illustrates the usage:
>>
>> ## Test using default object: java.util.Properties
>> #set $Name="Keats Kirsch"
>> #set $Age=45
>> <h3>\#properties test</h3>
>> #properties $p {
>> Name: $Name
>> Age = $Age
>> }
>> My age is $p.Age<br>
>> My name is $p.Name<br>
>> ## Test using a pre-existing POJO (non-map)
>> <h3>More \#properties</h3>
>> #bean $Cal="java.util.Calendar" scope=static
>> #set $GCal=$Cal.Instance
>> Today: $GCal.Time, FirstDayOfWeek: $GCal.FirstDayOfWeek, Lenient:
>> $GCal.Lenient
>> <br>
>> #properties $GCal {
>> FirstDayOfWeek=0
>> Lenient=false
>> }
>> Today: $GCal.Time, FirstDayOfWeek: $GCal.FirstDayOfWeek, Lenient:
>> $GCal.Lenient
>> <br>
>>
>>------------------------------------------------------------------------
>>
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click