简体   繁体   English

未定义的子程序&main :: ThrowTemplateError

[英]undefined subroutine &main::ThrowTemplateError

following is my template code : 以下是我的模板代码:

<html>
<head>
<style>

.table
{
    display:table;
    border-collapse:separate;
    border-spacing:2px;
}
.thead
{
    display:table-header-group;
    color:white;
    font-weight:bold;
    background-color:grey;
}
.tbody
{
    display:table-row-group;
}

.tr
{
    display:table-row;
}
.td
{
    display:table-cell;
    border:1px solid black;
    padding:1px;
}
.tr.editing .td INPUT
 width:100px;
}
</style>
<script type = "text/javascript" src = "jquery.min.js"></script>
<script>
var counter = 0;
var txt1 = "group_save";
function addNew() {
// Get the main Div in which all the other divs will be added
var mainContainer = document.getElementById('mainContainer');
// Create a new div for holding text and button input elements
var newDiv = document.createElement('div');
// Create a new text input
var newText = document.createElement('input');
newText.type = "input";
newText.name = txt1+counter;
//newText.value = counter;
// Create a new button input
var newDelButton = document.createElement('input');
newDelButton.type = "button";
newDelButton.value = "Delete";
// Append new text input to the newDiv
newDiv.appendChild(newText);
// Append new button input to the newDiv
newDiv.appendChild(newDelButton);
// Append newDiv input to the mainContainer div
mainContainer.appendChild(newDiv);
counter++;
// Add a handler to button for deleting the newDiv from the mainContainer
newDelButton.onclick = function() {
mainContainer.removeChild(newDiv);
}
}
   function edit(element){
  var tr = jQuery(element).parent().parent();
    if(!tr.hasClass("editing")) {
            tr.addClass("editing");
            tr.find("DIV.td").each(function(){
                    if(!jQuery(this).hasClass("action")){
                            var value = jQuery(this).text();

                            jQuery(this).text("");
                            jQuery(this).append('<input type="text" value="'+value+'" />');

                    } else {
                            jQuery(this).find("BUTTON").text("save");
                    }
            });
    } else {
            tr.removeClass("editing");
            tr.find("DIV.td").each(function(){
                    if(!jQuery(this).hasClass("action")){
                            var value1 = jQuery(this).find("INPUT").val();
                            alert(value1);
                            jQuery(this).text(value1);
                            jQuery(this).find("INPUT").remove();
                    } else {
                            jQuery(this).find("BUTTON").text("edit");
                    }
            });
    }
}
</script>

</head>
<body >
<form name="group" method="post" action="process.cgi">
<div id="mainContainer">
<div><input type="button" value="Add" onClick="addNew()"></div>
 </div>
 <div><input type = "submit" value = "Save"></div>
</form>
[% IF count > 0%]

<b>Details of Groups</b><br>

<div class= "table">
<div class = "thead">
  <div class = "tr">

<div class = "td">ID</div>
<div class = "td">GROUP NAME</div>
<div class = "td">GROUP DESCRIPTION</div>
<div class = "td">IS ACTIVE</div>
<div class = "td"></div>
 </div>
</div>

<div class= "tbody">

[%- SET i = 0;
 WHILE i < id.size; -%]

 <form  class = "tr">
<div class = "td">&nbsp; [% id.$i %]<br/></div>
<div class = "td">&nbsp; [% group_name.$i %]<br/></div>
<div class = "td">&nbsp; [% group_desc.$i %]<br/></div>
<div class = "td">[% actv.$i %]<br/></div>
<div class = "td action" ><button type="button" onclick="edit(this);">edit</button>   </div>
<form>
[%-     SET i = i + 1;
END -%]
</div>
 </body>
</html>

while i run my cgi code, i got the following template error.i checked my code and didn't find that evident, which gives the error.could any one please help me track this error.so that, i can go with the rest of the modifications in the file.that is i want to save the changed content in the database.??? 当我运行我的CGI代码时,我收到以下模板错误。我检查了我的代码,却没有发现明显的错误,这给了错误。请问有人可以帮助我跟踪此错误吗?文件中的修改内容。也就是说,我要将更改后的内容保存在数据库中。

updated : 更新 :

error --- Undefined subroutine &main::ThrowTemplateError called at /var/www/html/centralbugzilla/groups.cgi line 24. 错误---未定义的子程序&main :: ThrowTemplateError在/var/www/html/centralbugzilla/groups.cgi第24行调用。

line no 24 is : $template->process("list/group.html.tmpl",$vars) || 第24行是:$ template-> process(“ list / group.html.tmpl”,$ vars)|| ThrowTemplateError($template->error()); ThrowTemplateError($ template-> error());

Firstly, you shouldn't assume that people will just know which templating system you are using. 首先,您不应该假设人们会知道您使用的是哪个模板系统。 It looks to me like you are using the Template Toolkit, but there are many template engines for Perl. 在我看来,您正在使用模板工具包,但是Perl有很多模板引擎。

Secondly, the template is a complete red herring here. 其次,此处的模板是完整的红色鲱鱼。 The problem is in your Perl code. 问题出在您的Perl代码中。 When the template can't be processed successfully, your code calls a function called ThrowTemplateError , but Perl can't find that function anywhere. 当无法成功处理模板时,您的代码将调用一个名为ThrowTemplateError的函数,但Perl在任何地方都找不到该函数。 Where is that function defined? 该功能在哪里定义?

(Ok, I suppose it could look like the problem is in your template and not the code. There's some error in your template which means that TT can't process it and therefore the missing function is called. So fixing the error in your template will mean that the missing function no longer gets called. But it's still missing. And it will be a problem again the next time you accidentally break your template. So best to fix it now, I think.) (好吧,我想这似乎是您的模板而不是代码中的问题。您的模板中存在一些错误,这意味着TT无法处理它,因此调用了缺少的函数。因此,请修复模板中的错误表示丢失的函数不再被调用。但是它仍然丢失。下次您不小心破坏模板时,这将再次成为问题。因此,我认为现在最好对其进行修复。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法读取未定义的属性'main' - Cannot read property 'main' of undefined SassError:未定义变量:“$main-background-color” - SassError: Undefined variable: "$main-background-color" Uncaught (in promise) TypeError: result.main is undefined - Uncaught (in promise) TypeError: result.main is undefined 在控制台中获取数据,但在主输出中显示未定义 - Getting data in console but shows undefined in main output 无法读取main.js中未定义的属性“ substr” - Cannot read property 'substr' of undefined in main.js 无法读取未定义的属性“main_text_matched_substrings” - Cannot read property 'main_text_matched_substrings' of undefined 来自PHP的JSON数组在主JS文件中未定义编码 - JSON Array from PHP encode in undefined in main JS file 为什么在主模块中使用时 setTimeout(0) 和 setImmediate() 的行为未定义? - Why is the behavior of setTimeout(0) and setImmediate() undefined when used in the main module? 使用Javascript生成的HTML表在主div中未定义 - Using Javascript generated HTML table yields undefined in my main div 调用异步 function,主线程不会停止,然后结果为 undefined - Calling an asynchronous function, main thread wont stop and then there is result with undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM