Edgewall Software

Opened 18 years ago

Closed 18 years ago

Last modified 14 years ago

#49 closed defect (fixed)

Lazy py:match

Reported by: waldemar.osuch@… Owned by: cmlenz
Priority: major Milestone: 0.3
Component: Template processing Version: 0.2
Keywords: Cc:

Description

When using the recipe http://markup.edgewall.org/wiki/MarkupRecipes/FormFilling the form stops to be autofilled after three inputs. Got tired? :)

from markup.template import Template

src="""
<html xmlns:py="http://markup.edgewall.org/">

<input py:match="form//input" py:attrs="select('@*')" value="${form[str(select('@name'))]}" />

<body>
    <form action="" method="POST">
    <table>
        <tr py:for="fn in sorted(form)">
            <td py:content="fn.capitalize()">Label:</td><td><input type="text" name="${fn}"/></td>
        </tr>
    </table>
    <input type="submit" value="Save"/>
  </form>
</body>
</html>
"""

tmpl = Template(src)
form = dict(('hello_%s' % i, i) for i in range(5))
print tmpl.generate(**dict(form=form)).render(method='html')

produces:

<html>
<body>
    <form action="" method="POST">
    <table>
        <tr>
            <td>Hello_0</td><td><input value="0" type="text" name="hello_0"></td>
        </tr><tr>
            <td>Hello_1</td><td><input value="1" type="text" name="hello_1"></td>
        </tr><tr>
            <td>Hello_2</td><td><input value="2" type="text" name="hello_2"></td>
        </tr><tr>
            <td>Hello_3</td><td><input type="text" name="hello_3"></td>
        </tr><tr>
            <td>Hello_4</td><td><input type="text" name="hello_4"></td>
        </tr>
    </table>
    <input type="submit" value="Save">
  </form>
</body>
</html>

Change History (1)

comment:1 Changed 18 years ago by cmlenz

  • Resolution set to fixed
  • Status changed from new to closed

Thanks for the report! This should be fixed in [273].

Note: See TracTickets for help on using tickets.