简体   繁体   中英

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

updated :

error --- Undefined subroutine &main::ThrowTemplateError called at /var/www/html/centralbugzilla/groups.cgi line 24.

line no 24 is : $template->process("list/group.html.tmpl",$vars) || 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.

Secondly, the template is a complete red herring here. The problem is in your Perl code. When the template can't be processed successfully, your code calls a function called ThrowTemplateError , but Perl can't find that function anywhere. 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.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM