perldoc > HTML::Mason::Component

📛 NAME

HTML::Mason::Component - Mason Component Class

🚀 Quick Reference

Use CaseCommandDescription
Get current component$comp = $m->current_compRetrieve the component currently being executed
Get a caller component$comp = $m->callers(1)Get the component that called this one (1 level up)
Fetch a component by path$comp = $m->fetch_comp('foo/bar')Load a component by its relative path
Get component title$comp->titlePrintable unique identifier for the component
Check for an attribute$comp->attr_exists('name')Returns true if the attribute exists
Check for a method$comp->method_exists('name')Returns true if the method exists
Get declared arguments$comp->declared_argsHashref of arguments from <%args>
Call a method and capture output$output = $comp->scall_method('name', @args)Call method and return output as string

📖 SYNOPSIS

    my $comp1 = $m->current_comp;
    my $comp2 = $m->callers(1);
    my $comp3 = $m->fetch_comp('foo/bar');

    foreach ($comp1,$comp2,$comp3) {
       print "My name is ".$_->title.".\n";
    }

📝 DESCRIPTION

Mason uses the Component class to store components loaded into memory. Components come from three distinct sources:

  1. 📄 File-based: loaded from a source or object file.
  2. 🧩 Subcomponents: embedded components defined with the <%def> or <%method> tags.
  3. 🕵️ Anonymous: created on-the-fly with the make_component Interp method.

Some of the methods below return different values (or nothing at all) depending on the component type.

The component API is primarily useful for introspection, e.g. "what component called me" or "does the next component take a certain argument". You can build complex Mason sites without ever dealing directly with a component object.

⚙️ CREATING AND ACCESSING COMPONENTS

Common ways to get handles on existing component objects include the Request->current_comp, Request->callers, and Request->fetch_comp methods.

There is no published new method, because creating a component requires an Interpreter. Use the make_component method to create a new component dynamically.

Similarly, there is no execute or call method, because calling a component requires a request. All of the interfaces for calling a component (<& &>, $m->comp, $interp->exec) which normally take a component path will also take a component object.

📋 METHODS

📁 FILE-BASED METHODS

The following methods apply only to file-based components (those loaded from source or object files). They return undef for other component types.

HTML::Mason::Component
📛 NAME 🚀 Quick Reference 📖 SYNOPSIS 📝 DESCRIPTION
⚙️ CREATING AND ACCESSING COMPONENTS
📋 METHODS 📁 FILE-BASED METHODS

Generated by phpman v4.9.29 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-20 23:09 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^