카테고리 없음

[펄] Mason 컴포넌트에 정의 된 여러 메소드를 호출하는 방법은 무엇입니까?

행복을전해요 2021. 1. 15. 17:00

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