diff --git a/atst/ui_modules.py b/atst/ui_modules.py index 0ced7fad..6773b5c6 100644 --- a/atst/ui_modules.py +++ b/atst/ui_modules.py @@ -1,4 +1,6 @@ from tornado.web import UIModule +# from tornado.template import raw +import re class Alert(UIModule): def render(self, title, message=None, actions=None, level='info'): @@ -9,6 +11,16 @@ class Alert(UIModule): actions=actions, level=level) +class TextInput(UIModule): + def render(self, input, placeholder=''): + return self.render_string( + "components/text_input.html.to", + input=input, + label=re.sub('<[^<]+?>', '', str(input.label)), + errors=input.errors, + placeholder=placeholder, + description=input.description) + class Icon(UIModule): def render(self, name, classes=''): with open('static/icons/%s.svg' % name) as svg: diff --git a/templates/components/text_input.html.to b/templates/components/text_input.html.to new file mode 100644 index 00000000..6d72884a --- /dev/null +++ b/templates/components/text_input.html.to @@ -0,0 +1,21 @@ +
+ + + {% raw input(placeholder=placeholder) %} + + {% if errors %} + {% for error in errors %} + {{ error }} + {% end %} + {% end %} +