def html(self, classes=()): if self.format == Format.HTML: data = sanitize_html(self.content) elif self.format == Format.MARKDOWN: data = markdown(self.content) text = Text(data, escape=False) return div(text, class_=classes)
def test_cannot_alter_id_of_non_tag_elements(self): x = Text('foo') with pytest.raises(AttributeError): x.id = 'bar'
def test_text_api(self): obj = Text('foo') with pytest.raises(TypeError): obj.add_child(obj)
def render_model(obj, role=None, request=None): return Text(str(obj))
def wrapped(obj, **kwargs): ctx = func(obj, **kwargs) request = ctx.get('request') data = renderer(context=ctx, request=request) return Text(data, escape=False)
def get_html(self, *args, **kwargs): return Text(self.get_data(*args, **kwargs), escape=False)
def render_type(_, role=None): return Text('html' if role is None else f'html-{role}')
def test_element_equality(): assert Text('foo') == Text('foo') assert p['foo'] == p['foo']
def render_template(kind, data, request, ctx): template = get_template(data, kind) rendered = template.render(ctx, request=request) return Text(rendered, escape=False)
def _(data, request, ctx): return Text(data)