Changes between Version 2 and Version 3 of Doc/panc/stdtpl/functions


Ignore:
Timestamp:
Nov 30, 2007, 11:48:02 AM (18 years ago)
Author:
/O=GRID-FR/C=FR/O=CNRS/OU=LAL/CN=Charles Loomis
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Doc/panc/stdtpl/functions

    v2 v3  
    1212Often one want to add elements to a resource (list or hash) incrementally with a sequence of assignment statements.  Those assignment statements usually being in different templates.  The following functions provide simple mechanisms to do so.
    1313
    14 """push(element...) """
     14'''push(element...)'''
     15
    1516This function will return a copy of self with the given value(s) appended to the end.  If self is undefined, the function will create a new list with the arguments and return that.  An example is
    1617{{{
     
    2930will leave '/mylist' with the one-element list 'b'.
    3031
    31    
     32'''push_if(boolean, element...)'''
     33
     34This function behaves exactly like push() except that the first argument determines whether or not to add the rest of the arguments to the value of self.  If the value is false, the function will return an empty list.  As for push(), this function will create a new list if self is undefined.  See also the warning about multiple calls to push() within the same DML block; this warning also applies here.
     35
     36'''npush(element...)'''
     37
     38This function will return a copy of self with the given value(s) inserted into the nlist.  The number of arguments must be even; each pair will be treated as a key/value.  If self is undefined, the function will create a new nlist with the arguments and return that.  An example is
     39{{{
     40  '/mylist' = npush('a',1);
     41  '/mylist' = npush('b',2);
     42}}}
     43The final value for '/mylist' will be a two-element nlist containing the key/value pairs ('a',1) and ('b',2). 
     44
     45Be careful because the value of self is not directly modified by the npush() function.  This means that the following:
     46{{{
     47  '/mylist' = {
     48    npush('a',1);
     49    npush('b',2);
     50  };
     51}}}
     52will leave '/mylist' with the one-element nlist with the key/value pair ('b',2).
     53
    3254
    3355== 'object' Utility Functions ==