2015-01-31 62 views
2

我有一個簡單的形式使用金字塔,我想用它作爲一個新的或更新。我不是特別想爲我的表單中的所有字段創建空字典值,我只是希望它在不引發異常的情況下忽略它們。金字塔忽略缺少模板變量

<div metal:fill-slot="content"> 
<form method="POST" action="/studentupdate"> 
    <input name="id" value="${studentid}" type="hidden" /> 
    Name: <input type="text" name="studentname" value="${studentname}"/><br /> 
    Exam Score: <input type="text" name="studentexam" value="${studentexam}"/><br /> 
    Quiz Score: <input type="text" name="studentquiz" value="${studentquiz}"/><br /> 
    Homework Score: <input type="text" name="studenthomework" value="${studenthw}"/><br /> 
    <input type="submit" value="Save"/> 
</form> 
</div> 

我該怎麼做?

謝謝。

回答

0

可以解決辦法這樣
${studentexam or ''}

% for i in missing_list or [] 
<li>${i}</li> 
% endfor