def escapenl_formatter(error): """ Formatter that escapes HTML, and translates newlines to ``<br>`` """ error = html_quote(error) error = error.replace('\n', '<br>\n') return error
def error_formatter(error): """ Custom htmlfill error formatter that doesn't add a <br/> (since this causes formatting problems on our forms). :param error: the error to format """ if error is None: return "" return '<span class="error-message">%s</span>\n' % html_quote(error)
def handle_textarea(self, attrs): name = self.get_attr(attrs, "name") if self.prefix_error: self.write_marker(name) if self.error_class and self.errors.get(name): self.add_class(attrs, self.error_class) self.write_tag("textarea", attrs) value = self.defaults.get(name, "") self.write_text(html_quote(value)) self.write_text("</textarea>") self.in_textarea = True self.last_textarea_name = name self.add_key(name)
def handle_textarea(self, attrs): name = self.get_attr(attrs, 'name') if self.prefix_error: self.write_marker(name) if (self.error_class and self.errors.get(name)): self.add_class(attrs, self.error_class) self.write_tag('textarea', attrs) value = self.defaults.get(name, '') self.write_text(html_quote(value)) self.write_text('</textarea>') self.in_textarea = True self.last_textarea_name = name self.add_key(name)
def escape_formatter(error): """ Formatter that escapes HTML, no more. """ return html_quote(error)
def default_formatter(error): """ Formatter that escapes the error, wraps the error in a span with class ``error-message``, and adds a ``<br>`` """ return '<span class="error-message">%s</span><br />\n' % html_quote(error)
def htmlfill_error_formatter(error): """ An error formatter to make the errors consistent with the js validate errors. """ from formencode.rewritingparser import html_quote return '<div class="error-container"><label class="error">%s</label></div>' % (html_quote(error))