undefined子例程& main :: ThrowTemplateError

时间:2013-06-28 08:32:19

标签: javascript jquery html perl template-toolkit

以下是我的模板代码:

<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>

当我运行我的cgi代码时,我得到了以下模板error.i检查了我的代码并没有找到明显的,这给出了error.could任何一个请帮我跟踪这个错误。所以,我可以去与文件中的其余修改。我想将更改的内容保存在数据库中。???

已更新:

错误--- 未定义的子例程&amp; main :: ThrowTemplateError在/var/www/html/centralbugzilla/groups.cgi第24行调用。

第24行是:$ template-&gt; process(“list / group.html.tmpl”,$ vars)       || ThrowTemplateError($模板 - &GT;误差());

1 个答案:

答案 0 :(得分:1)

首先,你不应该假设人们只知道你正在使用哪个模板系统。在我看来,您使用的是模板工具包,但Perl有许多模板引擎。

其次,模板在这里是一个完整的红鲱鱼。问题出在你的Perl代码中。当模板无法成功处理时,您的代码会调用一个名为ThrowTemplateError的函数,但Perl无法在任何地方找到该函数。该函数定义在哪里?

(好吧,我想它可能看起来问题出现在你的模板而不是代码中。你的模板中有一些错误,这意味着TT无法处理它,因此调用了缺失的函数。所以修复错误在你的模板中意味着丢失的函数不再被调用。但它仍然缺失。下次你不小心破坏你的模板时会再次出现问题。我认为现在最好修复它。)

相关问题