Forum OpenACS Q&A: Response to if/else tags in adp

Posted by Michael A. Cleverly on
Here is a short shell script that can help identify problems with .adp's. (Improperly closed <if> & <else> tags, improperly nested tags, etc.) In fact, it's more rigorous about well-formed .adp code than the ACS code. I wrote it to help our graphic designer find a missing </if> in an .adp that had grown to several thousand lines long.

Usage: save as adp-validate, stick it somewhere in your $PATH and then run: adp-validate *.adp from a shell.

# -*- tcl -*- 
exec tclsh "$0" "$@"

package require Tcl 8.3
package require nstcl-templating
package require fileutil
foreach file $argv {
    if [catch {
        ::nstcl::template::adp::adp_to_pseudo_code [fileutil::cat $file]
    } problem] {
        puts stderr "$file ==> $problem"
    } else {
        puts "$file ==> OK"