{
    "mode": "perldoc",
    "parameter": "Template::Namespace::Constants",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Template%3A%3ANamespace%3A%3AConstants/json",
    "generated": "2026-11-09T11:09:26Z",
    "synopsis": "# easy way to define constants\nuse Template;\nmy $tt = Template->new({\nCONSTANTS => {\npi => 3.14,\ne  => 2.718,\n},\n});\n# nitty-gritty, hands-dirty way\nuse Template::Namespace::Constants;\nmy $tt = Template->new({\nNAMESPACE => {\nconstants => Template::Namespace::Constants->new({\npi => 3.14,\ne  => 2.718,\n},\n},\n});",
    "sections": {
        "NAME": {
            "content": "Template::Namespace::Constants - Compile time constant folding\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "# easy way to define constants\nuse Template;\n\nmy $tt = Template->new({\nCONSTANTS => {\npi => 3.14,\ne  => 2.718,\n},\n});\n\n# nitty-gritty, hands-dirty way\nuse Template::Namespace::Constants;\n\nmy $tt = Template->new({\nNAMESPACE => {\nconstants => Template::Namespace::Constants->new({\npi => 3.14,\ne  => 2.718,\n},\n},\n});\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The \"Template::Namespace::Constants\" module implements a namespace handler which is plugged into\nthe \"Template::Directive\" compiler module. This then performs compile time constant folding of\nvariables in a particular namespace.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "new(\\%constants)\nThe new() constructor method creates and returns a reference to a new\nTemplate::Namespace::Constants object. This creates an internal stash to store the constant\nvariable definitions passed as arguments.\n\nmy $handler = Template::Namespace::Constants->new({\npi => 3.14,\ne  => 2.718,\n});\n\nident(\\@ident)\nMethod called to resolve a variable identifier into a compiled form. In this case, the method\nfetches the corresponding constant value from its internal stash and returns it.\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::Directive\n",
            "subsections": []
        }
    },
    "summary": "Template::Namespace::Constants - Compile time constant folding",
    "flags": [],
    "examples": [],
    "see_also": []
}