def make_text(**kwargs): h = HTML() try: args = { 'id': 'text-' + str(kwargs['number']), 'data-editor-type': "textarea", 'data-editor-placeholder': kwargs['editor_placeholder'], 'data-editor-label': kwargs['editor_label'], 'data-editor-default': kwargs['editor_default'], 'style': kwargs.get('style') or 'text-align:justify', 'klass': 'text' } except KeyError: args = { 'id': 'text-' + str(kwargs['number']), 'data-editor-type': "textarea", 'data-editor-placeholder': "Text", 'data-editor-label': 'Text', 'data-editor-default': "Text", 'style': kwargs.get('style') or 'text-align:justify', 'klass': 'text' } if kwargs['content'] is not None: text = kwargs['content']['text-' + str(kwargs['number'])]['text'] args = args['data-editor-default'] = text if 'max_chars' in kwargs: args['data-editor-max-chars'] = str(kwargs['max_chars']) h.div('', **args) return str(h)
def make_text(**kwargs): if 'content' in kwargs and 'number' in kwargs: id = 'text-' + str(kwargs['number']) text = kwargs['content'][id]['text'] wrap_in_div = kwargs['wrap_in_div'] if 'wrap_in_div' in kwargs else True if wrap_in_div: h = HTML() h.div(text, klass='text', style=kwargs.get('style') or 'text-align: justify;', escape=False) rendered = str(h) else: rendered = text return rendered