{
    "mode": "perldoc",
    "parameter": "Template::Plugin::HTML",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Template%3A%3APlugin%3A%3AHTML/json",
    "generated": "2026-06-13T00:21:29Z",
    "synopsis": "[% USE HTML %]\n[% HTML.escape(\"if (a < b && c > d) ...\" %]\n[% HTML.element(table => { border => 1, cellpadding => 2 }) %]\n[% HTML.attributes(border => 1, cellpadding => 2) %]",
    "sections": {
        "NAME": {
            "content": "Template::Plugin::HTML - Plugin to create HTML elements\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "[% USE HTML %]\n\n[% HTML.escape(\"if (a < b && c > d) ...\" %]\n\n[% HTML.element(table => { border => 1, cellpadding => 2 }) %]\n\n[% HTML.attributes(border => 1, cellpadding => 2) %]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The \"HTML\" plugin is a very basic plugin, implementing a few useful methods for generating HTML.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "escape(text)\nReturns the source text with any HTML reserved characters such as \"<\", \">\", etc., correctly\nescaped to their entity equivalents.\n\nattributes(hash)\nReturns the elements of the hash array passed by reference correctly formatted (e.g. values\nquoted and correctly escaped) as attributes for an HTML element.\n\naddattribute(attributes)\nThis provides a way to incrementally add attributes to the object. The values passed in are\nstored in the object. Calling element with just a tag or attributes without an parameters will\nused the saved attributes.\n\nUSE tag = HTML;\ntag.addattributes( { class => 'navbar' } );\ntag.addattributes( { id => 'foo' } );\ntag.addattributes( { class => 'active' } );\n\ntag.element( 'li' ); # <li class=\"navbar active\" id=\"foo\">\n\nThis method has two aliases: addattribute() and add().\n\nreplaceattribute(attributes)\nThis will replace an attribute value instead of add to existing.\n\nUSE tag = HTML;\ntag.addattributes( { class => 'navbar' } );\ntag.addattributes( { id => 'foo' } );\ntag.replaceattributes( { class => 'active' } );\n\ntag.element( 'li' ); # <li class=\"active\" id=\"foo\">\n\nThis method has two aliases: replaceattribute() and replace().\n\nclearattributes\nClears any saved attributes\n\nelement(type, attributes)\nGenerates an HTML element of the specified type and with the attributes provided as an optional\nhash array reference as the second argument or as named arguments.\n\n[% HTML.element(table => { border => 1, cellpadding => 2 }) %]\n[% HTML.element('table', border=1, cellpadding=2) %]\n[% HTML.element(table => attribs) %]\n",
            "subsections": []
        },
        "DEBUGGING": {
            "content": "The HTML plugin accepts a \"sorted\" option as a constructor argument which, when set to any true\nvalue, causes the attributes generated by the \"attributes()\" method (either directly or via\n\"element()\") to be returned in sorted order. Order of attributes isn't important in HTML, but\nthis is provided mainly for the purposes of debugging where it is useful to have attributes\ngenerated in a deterministic order rather than whatever order the hash happened to feel like\nreturning the keys in.\n\n[% USE HTML(sorted=1) %]\n[% HTML.element( foo => { charlie => 1, bravo => 2, alpha => 3 } ) %]\n\ngenerates:\n\n<foo alpha=\"3\" bravo=\"2\" charlie=\"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::HTML - Plugin to create HTML elements",
    "flags": [],
    "examples": [],
    "see_also": []
}