construct
대신 사용load
에서 perldoc Mason::Request
:
load (path) Makes the component path absolute if necessary, and calls Interp load to load the component class associated with the path.
...
construct (path[, params ...]) Constructs and return a new instance of the component designated by path params, if any, are passed to the constructor. Throws an error if path does not exist.
로드는 사용 가능한 객체를 반환하지 않지만 생성은 할 것입니다.
다음은 나를 위해 일했습니다 /test.mc
.
<%init>
my $namecomp = $m->construct('name.mi', name=>'john');
</%init>
<% $namecomp->text %>
<% $namecomp->showname %>
출처
https://stackoverflow.com/questions/22006835