【发布时间】:2021-05-23 21:07:24
【问题描述】:
我正在为 Dancer 使用 Mason2 模板。当我尝试在模板中调用“Dancer qw(session)”时,出现如下错误。我只是用显示 index.mc 模板的根路由编写“hello world”应用程序。我已经安装了最新的 perl 5.26 和 Dancer 版本 1.3513。
模板:
<%class>
use Dancer qw(session);
</%class>
<%augment wrap>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Portal</title>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<body>
<div class="container">
<div class="page-header">
TESTING
<br>
<% inner() %>
</body>
</html>
</%augment>
错误:
Couldn't find declarator 'method' at C:/Strawberry/perl/vendor/lib/Devel/Declare/Context/Simple.pm line 47.
Devel::Declare::Context::Simple::skip_declarator(Method::Signatures::Simple=HASH(0x5df6ac8)) called at C:/Strawberry/perl/vendor/lib/Devel/Declare/MethodInstaller/Simple.pm line 62
Devel::Declare::MethodInstaller::Simple::parser(Method::Signatures::Simple=HASH(0x5df6ac8), "method", 0, 1) called at C:/Strawberry/perl/vendor/lib/Devel/Declare/MethodInstaller/Simple.pm line 25
我错过了什么?
【问题讨论】:
-
你为什么要在这里导入模块 Dancer?
-
新代码请使用Dancer2。另请检查文档以了解正确使用方法。
-
既然 Dancer2 存在,我真的不推荐使用 Dancer。我当然不会推荐 Mason 而不是 Template Toolkit。
-
导入模块 dancer 的想法是在会话中添加一些其他“数据”。从 Dancer 和 Mason2 迁移到 Dancer2 和 Template toolkit 似乎需要做很多工作。