template::parse_directives (public)
template::parse_directives code
Defined in packages/acs-templating/tcl/doc-procs.tcl
Parse out directives embedded in the code parameter.
- Parameters:
- code (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: # remove carriage returns if present regsub -all -- {\r|\r\n} $code {\n} code # remove extra blank lines regsub -all -- {(\n)\n} $code {\1} code set lines [split $code "\n"] # regular expression for match directive comments set direxp {^\#[\s]*@([a-zA-Z0-9\-_]+)[\s]+(.*)$} set directives [list] foreach line $lines { if { [regexp $direxp $line x next_directive next_comment] } { # start a new directive if { [info exists directive] } { # finish last directive lappend directives [list $directive $comment] } set directive $next_directive set comment $next_comment } elseif { [info exists directive] } { if { [regexp {^\#\s*(.*)$} $line x add_comment] } { # append this line to the current directive append comment " $add_comment" } else { # finish directive lappend directives [list $directive $comment] unset directive unset comment } } } if { [info exists directive] } { lappend directives [list $directive $comment] } return $directivesXQL Not present: Generic, PostgreSQL, Oracle