{
    "mode": "perldoc",
    "parameter": "Template::Plugin::URL",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Template%3A%3APlugin%3A%3AURL/json",
    "generated": "2026-06-13T20:08:08Z",
    "synopsis": "[% USE url('/cgi-bin/foo.pl') %]\n[% url(debug = 1, id = 123) %]\n# ==> /cgi/bin/foo.pl?debug=1&amp;id=123\n[% USE mycgi = url('/cgi-bin/bar.pl', mode='browse', debug=1) %]\n[% mycgi %]\n# ==> /cgi/bin/bar.pl?mode=browse&amp;debug=1\n[% mycgi(mode='submit') %]\n# ==> /cgi/bin/bar.pl?mode=submit&amp;debug=1\n[% mycgi(debug='d2 p0', id='D4-2k[4]') %]\n# ==> /cgi-bin/bar.pl?mode=browse&amp;debug=d2%20p0&amp;id=D4-2k%5B4%5D",
    "sections": {
        "NAME": {
            "content": "Template::Plugin::URL - Plugin to construct complex URLs\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "[% USE url('/cgi-bin/foo.pl') %]\n\n[% url(debug = 1, id = 123) %]\n# ==> /cgi/bin/foo.pl?debug=1&amp;id=123\n\n[% USE mycgi = url('/cgi-bin/bar.pl', mode='browse', debug=1) %]\n\n[% mycgi %]\n# ==> /cgi/bin/bar.pl?mode=browse&amp;debug=1\n\n[% mycgi(mode='submit') %]\n# ==> /cgi/bin/bar.pl?mode=submit&amp;debug=1\n\n[% mycgi(debug='d2 p0', id='D4-2k[4]') %]\n# ==> /cgi-bin/bar.pl?mode=browse&amp;debug=d2%20p0&amp;id=D4-2k%5B4%5D\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The \"URL\" plugin can be used to construct complex URLs from a base stem and a hash array of\nadditional query parameters.\n\nThe constructor should be passed a base URL and optionally, a hash array reference of default\nparameters and values. Used from with a template, it would look something like the following:\n\n[% USE url('http://www.somewhere.com/cgi-bin/foo.pl') %]\n[% USE url('/cgi-bin/bar.pl', mode='browse') %]\n[% USE url('/cgi-bin/baz.pl', mode='browse', debug=1) %]\n\nWhen the plugin is then called without any arguments, the default base and parameters are\nreturned as a formatted query string.\n\n[% url %]\n\nFor the above three examples, these will produce the following outputs:\n\nhttp://www.somewhere.com/cgi-bin/foo.pl\n/cgi-bin/bar.pl?mode=browse\n/cgi-bin/baz.pl?mode=browse&amp;debug=1\n\nNote that additional parameters are separated by '\"&amp;\"' rather than simply '\"&\"'. This is the\ncorrect behaviour for HTML pages but is, unfortunately, incorrect when creating URLs that do not\nneed to be encoded safely for HTML. This is likely to be corrected in a future version of the\nplugin (most probably with TT3). In the mean time, you can set $Template::Plugin::URL::JOINT to\n\"&\" to get the correct behaviour.\n\nAdditional parameters may be also be specified to the URL:\n\n[% url(mode='submit', id='wiz') %]\n\nWhich, for the same three examples, produces:\n\nhttp://www.somewhere.com/cgi-bin/foo.pl?mode=submit&amp;id=wiz\n/cgi-bin/bar.pl?mode=browse&amp;id=wiz\n/cgi-bin/baz.pl?mode=browse&amp;debug=1&amp;id=wiz\n\nA new base URL may also be specified as the first option:\n\n[% url('/cgi-bin/waz.pl', test=1) %]\n\nproducing\n\n/cgi-bin/waz.pl?test=1\n/cgi-bin/waz.pl?mode=browse&amp;test=1\n/cgi-bin/waz.pl?mode=browse&amp;debug=1&amp;test=1\n\nThe ordering of the parameters is non-deterministic due to fact that Perl's hashes themselves\nare unordered. This isn't a problem as the ordering of CGI parameters is insignificant (to the\nbest of my knowledge). All values will be properly escaped thanks to some code borrowed from\nLincoln Stein's \"CGI\" module. e.g.\n\n[% USE url('/cgi-bin/woz.pl') %]\n[% url(name=\"Elrich von Benjy d'Weiro\") %]\n\nHere the spaces and \"\"'\"\" character are escaped in the output:\n\n/cgi-bin/woz.pl?name=Elrich%20von%20Benjy%20d%27Weiro\n\nAn alternate name may be provided for the plugin at construction time as per regular Template\nToolkit syntax.\n\n[% USE mycgi = url('cgi-bin/min.pl') %]\n[% mycgi(debug=1) %]\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Andy Wardley <abw@wardley.org> <http://wardley.org/>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved.\n\nThis module is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Template::Plugin\n",
            "subsections": []
        }
    },
    "summary": "Template::Plugin::URL - Plugin to construct complex URLs",
    "flags": [],
    "examples": [],
    "see_also": []
}