组件中 Mason 块的执行顺序是什么

What is the order of execution of Mason blocks in a component

如果这些块出现在 Mason 组件中,执行顺序是什么?

该列表中有两种不同的方块。 “可执行”块,其中包含可执行的 perl 代码,以及不可执行的块,其中包含键值对(与 perl 散列不同)。

可执行块

<%一次>

This block is executed whenever the component is loaded into memory. It is executed before any other block.

<%共享>

This block is executed once per request. It is executed before the <%init> block.

<%init>

This block is executed every time the component is called. It is executed before any other code except for code in <%once> or <%shared> blocks.

不可执行块

<%args>

This block is used to declare the arguments that a component expects. In addition, it can also be used to specify a default value if none is given when the component is called.

<%flags>

This block is used to declare special Mason flags, which are used to affect the component's behavior. Currently, there is only one flag defined, inherit.

<%attr>

This block is used to declare arbitrary key-value pairs. Unlike the <%flags> block, the contents are not used by Mason but may be used in your code.

有关详细信息,请参阅 Mason book,其中复制(和修改)了上面的一些内容。