使用Catalyst框架,如何在wrapper.tt中检查uri路径

问题描述 投票:0回答:1

我喜欢在wrapper.tt中检查路径,因此我可以根据路径动态包含链接。但是在广泛的在线搜索之后,我想不出在tt文件中获取路径的方法。例如,我可以检查用户是否已登录,如果是,则显示用户名,如下所示。谢谢。

[% IF c.user_exists %]
    <h4 style="float:right;">[% c.user.username %] <a href="/logout">logout</a></h4>
[% ELSE %]
    <h4 style="float:right;"><a href="/login">login</a></h4>
[% END %]
frameworks catalyst
1个回答
0
投票

我得到了答案。 c.req.path是uri路径。

© www.soinside.com 2019 - 2024. All rights reserved.