template::url (public)

 template::url command [ args... ]

Defined in packages/acs-templating/tcl/query-procs.tcl

Maintains an ns_set of parameters that can be bulk converted to URL parameters. It is not clear if this API makes a lot of sense, many alternatives exist to export parameters in various forms...

Parameters:
command (required)
one of 'set_param *name* *value*' (set a parameter), 'get_param *name* *default*' (get a parameter value), or 'get_query' (export all parameters as URL query).
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 template::filter template::filter (public) template::url template::url template::filter->template::url

Testcases:
No testcase defined.
Source code:

    global __template_url_params
    upvar 0 __template_url_params params

    if { ! [info exists params] } {
        set params [ns_set create]
    }

    set result ""

    switch -exact $command {

        set_param {
            lassign $args name value
            ns_set put $params $name $value
        }

        get_param {
            lassign $args name default
            if { [ns_set find $params $name] != -1 } {
                set result [ns_set iget $params $name]
            } else {
                set result $default
            }
        }

        get_query {
            set keyvalues [list]
            foreach {key value} [ns_set array $params] {
                lappend keyvalues [ns_urlencode $key]=[ns_urlencode $value]
            }
            set result [join $keyvalues &]
        }

        default {
            error "Invalid command for url: must be set_param, get_param or get_query"
        }

    }

    return $result
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: