# Slim template files generated by Cutter will have a first line
# of (commented) text that tells the ::Slim::RegisterLazyTemplates
# procedure in which menu the template should be placed. A typical
# first line might be,
#          # menuInfo fundza,MyColor#0 color MyColor utility
# This line of text has the effect of telling Slim that a template
# named "MyColor" implements a color node. As a menu item it 
# should be labelled "MyColor" and should appear in the "Utility"
# sub-menu of the "Colors" menu that is displayed by Slim.
# Author: Malcolm Kesson October 21 2007
set userdir FULL_PATH_TO_YOUR_SLIM_DIR/slim
if { [file exists $userdir] } {
    set slimfiles [glob -nocomplain -directory $userdir *slim]
    foreach item $slimfiles {
        set slimName [file tail $item]
        set fileID [open $userdir/$slimName r]
        # Read the first line of text
        gets $fileID info
        close $fileID
        # Remove the comment character and any leading white
        # space 
        set info [string trimleft $info "\# "]
        # Does the line begin with the "menuInfo" tag?
        if { [string equal -nocase -length 8 $info "menuInfo"] == 0} {
        set info [string trimleft $info]
        # Remove the tag
        set info [string range $info 8 end]
        set info [string trimleft $info]
        set rltStr     "::Slim::RegisterLazyTemplates \{\n"
        append rltStr  "    $userdir/$slimName \{\n"
        append rltStr  "        \{ $info \}\n"
        append rltStr  "    \}\n"
        append rltStr  "\}"
        eval $rltStr