2

这是我的 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' }

我哪里错了??

4

1 回答 1

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>
于 2012-10-17T14:35:15.197 回答