TPLTALK TplTalk (TemplateTalk) is an open standard programming interface for template based content processing like cgi/form-processing or complex server-based editing systems. * TECHNICAL INFO interface: call: parse(*input_hash,*template_array,*out_stream,*error_sub,GMToffsets_secs) breaks to sub *error_sub(string,fatalflag) streaming: processes a given hash of vars/parameters agains a template. results: modified param-hash, standard output in *out_stream, erros will be returned to *error_sub (syntax and runtime errors will return with fatalflag set to 1, breaks will return with fatalflag 0). templates may contain the following TAGs: all TAGs enclosed in or (white space compliant, not case sensitive, one statement per tag) fields/vars are designated by [x] = value of param x. nested, indexed or compound values allowed: xmp: [a]=x [b]=a => [[b]] == [a] => [[a][b]] == [x[b]] == [xa] SYNTAX: values: [x] ... simple include ( prints value of param/var "x") [x] (+|-|*|/|%|.) ... compound include (prints result) may be any single designated or bare value or any simple arithmetic combination starting with a value. xmp: [x]+2, [x] + (2+[y])*8, formated number output: [x] UNF ... universal number format (10000.0 => 10 000.0) [x] ENF ... european number format (10000.0 => 10.000,0) assignments: [x] [+|-|.|/|%]= ... assignment to [x] xmp: [x] *= 4+5, [x] = "word", [x]= ([y]+2) *10, [x]=5 [x] (++|--) .. increment|decrement [x] [x] =~ ... substitute with reg.exp. syntax is Perl syntax; no eval flag allowed. xmp: [x] =~ s/foo(\d+)/bar$1/ [x] =~ s/(foo|bar)[\d\w]\1/z/gi if/else (may nest): pattern: foo bar foobar ! ... negative value of condition may be any of the following: [x] (<|>|<=|>=|==|!=|=) ... compare [x] and expression [x] (=~|!~) (p.e.: "") [x] ... simple test for existence ("","0" are false values) ... test for negative existence [x] isnumber ... test for unsigned float or int, no white space [x] isint ... test for (signed) integer [x] isbareint ... test for unsigned integer [x] isfloat ... test for (signed) float [x] isbarefloat ... test for unsigned float [x] isreal ... same as "[x] isfloat" [x] ismail ... test for valid mail address loops: foobar (use indexed fields as "[[x][y]]" or "[x[y]]" inside loops.) format/round: FORMAT [x] ... formats [x] to printf-pattern xmp: [x]=4 format [x] %02d => prints "04" ROUND [x] n ... rounds and formats [x] to n fractions is n equal zero or n omitted [x] will be rounded to the next integer xmp: [x]=0.2 round [x] 2 => prints "0.20" (same as '') [x]=0.256 round [x] 1 => prints "0.3" others: RAND [x] ... assign random 0 > n < 1 to [x] BREAK errorstring ... break (with optional error message incl. values) LIST ... dumps input-parameters in name:value pairs DUMP ... dumps input-parameters without [xvar_...] params in [name]value pairs date and time stamps (all GMT) DATE ... full date (Mon. DD YYYY HH.MM GMT) GMTSTRING ... date (GMT-string) YYYYMMDD ... date (YYYY/MM/DD) DDMMYYYY ... date (DD.MM.YYYY) HHMM ... time (HH:MM) HHMMSS ... time (HH:MM:SS) comments: trailing '#', e.g.: reservered parameters: use [xvar_...] for control vars (won't be dumped, listed separately) p.e.: [xvar_mailfunction], [xvar_mailto]; * SYNTAX EXAMPLES # simple value tags: Send me T-shirts. # arithmetic expressions: Send me T-shirts à EUR for EUR . # assignments: # refernced values: let's suppose [currency] holds the value 'ATS' Send me T-shirts à EUR ( ) for EUR ( ). => 'Send me 5 T-shirts à EUR 1.20 (ATS 16.51236) for EUR 6 (ATS 82.5618).' # rounded values: Send me T-shirts à EUR ( ) for EUR ( ). => 'Send me 5 T-shirts à EUR 1.20 (ATS 16.51) for EUR 6 (ATS 82.55).' # formated ouput: Formated: UNF: ENF: => Formated: 125300.10 UNF: 125 300.10 ENF: 125.300,10 # conditions: Yes, I want my T-shirt, I am paying by creditcard money order cheque enclosed other: . No, I don't want no T-shirt. # loops (indexed variables): Article : Option : or: Article or: Article : Option: # regular expressions conditions: substitutions: mass:werk / Norbert Landsteiner 10.1999