== Extending tcl to generate html ==
[CMcC] Following from [jenglish]'s comment: why learn to use a monster HTML-template library when you can, with a few lines of code, extend the base language so you can write things like [[ href "/home.html" { ! "Home" }]] ... I wrote the following to do just that using the techniques in [let unknown know].
package require know
know {[string match <*> [lindex $args 0]]} {
set tag [string trim [lindex $args 0] "<>"]
::proc ::<$tag> {args} [string map [list @T $tag] {
set result {}
foreach {n v} [lrange $args 0 end-1] {
lappend result "$n='[armour $v]'"
}
return "<@T [join ${result}]>[lindex $args end]@T>"
}]
return [eval $args]
}
This will generate a proc for any command like [[