这是我的Mako代码,但是当我在服务器Cherrypy中使用此代码时出现错误。 错误是
SyntaxException: (SyntaxError) invalid syntax (<unknown>, line 1) (u"c=inputp${k}_id\nsomeval= ${urld['kwargs']['${c}']}") in file '/home/user/Scaricati/prototypefin/template/web_editor_parameter_settings.html' at line: 164 char: 1
我错了这段代码?我必须尝试,如果有相关值并打印其内容
<div id="sortparam" >
<%
k = 1
a=99
%>
<ul class="ui-sortable" id="sorpara">
% for k in a:
<%
c=inputp${k}_id
someval= ${urld['kwargs']['${someval}']}
%>
% if someval is UNDEFINED:
<% break %>
% else:
<li id="inputp${id}_id" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>${someval}</li>
% endif
% endfor
</ul>
</div>
啊,我想念变量kwargs是什么? Kwargs是我文件的内容
{'demo_title': 'Demo title', 'demo_input_description': 'hola mundo ', 'demo_params_description': ' ', 'demo_wait_description': ' ', 'demo_result_description': ' ', 'images_config_file': 'cfgmydemo.cfg', 'demo_data_filename': 'data_saved.cfg', 'tag': '', 'inputdata1_id': 'id_lsd', 'inputdata1_max_pixels': '1024000' }
哪里错了?
答案 0 :(得分:1)
尝试使用此代码:
<div id="sortparam" >
<%
k = 1
a=99
%>
<ul class="ui-sortable" id="sorpara">
% for k in a:
<%
c='inputp'+k+'_id'
%>
% if c in urld['kwargs'] :
<li id="inputp${k}_id" class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>${urld['kwargs']['${c}']}</li>
% endif
% endfor
</ul>
</div>