1

For a generic form checker I want to generate html <input> fields plus internationalized error messages (and default values, ...) while using templates to define which fields are in the form.

Template example:

...
<form>
  ${structure: make_field('email')}
</form>

Rendered template:

...
<form>
  <input type="text" name="email" ... /><span>error message</span>
</form>

Problem:

The error message for each field is specified using gettext like _('error123'). Because the html string is constructed by code I have to translate() the error message myself. Therefore I have to hand in a localizer to the form checker code which I want to avoid.

Is it possible to move the rendering completely to the template engine. Maybe with macros generated in code?!

Knut
  • 431
  • 4
  • 14
  • You'll need to provide information here about how `make_field` is implemented; does it use a form framework? – malthe Mar 09 '14 at 07:37

0 Answers0