Difference between revisions of "Jk-voting-template"
Jump to navigation
Jump to search
m (Reverted edit of 71.130.196.168, changed back to last version by WikiSysop) |
|||
Line 1: | Line 1: | ||
− | proc template {fn keyset} { set h [[open | + | proc template {fn keyset} { |
+ | set h [[open "[ns_info pageroot]]/templates/$fn" r] | ||
+ | set cont [[read $h]] | ||
+ | close $h | ||
+ | |||
+ | set keymap "" | ||
+ | for {set x 0} {$x < [[ns_set size $keyset]]} {incr x} { | ||
+ | set key [[ns_set key $keyset $x]] | ||
+ | set value [[ns_set value $keyset $x]] | ||
+ | lappend keymap "%%%%$key%%%%" | ||
+ | lappend keymap $value | ||
+ | } | ||
+ | if {$keymap != ""} { | ||
+ | set cont [[string map $keymap $cont]] | ||
+ | } | ||
+ | return $cont | ||
+ | } |
Revision as of 03:11, 19 March 2006
proc template {fn keyset} {
set h [[open "[ns_info pageroot]]/templates/$fn" r] set cont read $h close $h
set keymap "" for {set x 0} {$x < ns_set size $keyset} {incr x} { set key ns_set key $keyset $x set value ns_set value $keyset $x lappend keymap "%%%%$key%%%%" lappend keymap $value } if {$keymap != ""} { set cont string map $keymap $cont } return $cont }