From: Keats K. <ke...@xa...> - 2005-07-30 20:33:54
|
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> |