class IndexPage(Page): header = Header('iommi examples') form_header = Header('Form examples') # We can create html fragments... f_a_1 = html.a('Example 1: echo submitted data', attrs__href="form_example_1/") f_b_1 = html.br() f_a_2 = html.a('Example 2: create a Foo', attrs__href="form_example_2/") f_b_2 = html.br() f_a_3 = html.a('Example 3: edit a Foo', attrs__href="form_example_3/") f_b_3 = html.br() f_a_4 = html.a('Example 4: custom buttons', attrs__href="form_example_4/") f_b_4 = html.br() f_a_5 = html.a('Example 5: automatic AJAX endpoint', attrs__href="form_example_5/") f_b_5 = html.br() f_a_k = html.a('Kitchen sink', attrs__href="form_kitchen/") table_header = Header('Table examples') # ...or just throw a big chunk of html in here table_links = mark_safe(""" <a href="table_readme_example_1/">Example 1 from the README</a><br> <a href="table_readme_example_2/">Example 2 from the README</a><br> <a href="table_auto_example_1/">Example 1 of auto table</a><br> <a href="table_auto_example_2/">Example 2 of auto table</a><br> <a href="table_kitchen_sink/">Kitchen sink</a><br> <a href="table_as_view/">Table.as_view() example</a><br> """) page_header = Header('Page examples') page_links = mark_safe(""" <a href="page_busy/">A busy page with lots of stuff</a><br> <a href="all_field_sorts">Show different type of form field types</a><br> <a href="all_column_sorts">Show different type of table column types</a> """) menu_header = Header('Menu examples') menu_examples = mark_safe(""" <a href="menu_test/">A menu example</a><br> """) # You can also nest pages admin = AdminPage() select_style = StyleSelector()
class IndexPage(Page): header = html.h1('iommi examples') form_header = html.h2('Form examples') # We can create html fragments... f_a_1 = html.a('Example 1: echo submitted data', attrs__href="form_example_1/") f_b_1 = html.br() f_a_2 = html.a('Example 2: create a Foo', attrs__href="form_example_2/") f_b_2 = html.br() f_a_3 = html.a('Example 3: edit a Foo', attrs__href="form_example_3/") f_b_3 = html.br() f_a_4 = html.a('Example 4: custom buttons', attrs__href="form_example_4/") f_b_4 = html.br() f_a_5 = html.a('Example 5: automatic AJAX endpoint', attrs__href="form_example_5/") f_b_5 = html.br() f_a_k = html.a('Kitchen sink', attrs__href="form_kitchen/") table_header = html.h2('Table examples') # ...or just throw a big chunk of html in here table_links = mark_safe(""" <a href="table_readme_example_1/">Example 1 from the README</a><br> <a href="table_readme_example_2/">Example 2 from the README</a><br> <a href="table_kitchen_sink/">Kitchen sink</a><br> """) page_header = html.h2('Page examples') page_links = mark_safe(""" <a href="page_busy/">A busy page with lots of stuff</a><br> """) # You can also nest pages admin = AdminPage()
class IndexPage(ExamplesPage): header = html.h1('Form examples') description = html.p('Some examples of iommi Forms') all_fields = html.p( Action( display_name='Example with all types of fields', attrs__href='all_fields', ), html.br(), after='example_11', ) class Meta: parts = example_links(examples)
def example_links(examples): children = {} for i, example in enumerate(examples): n = i + 1 children[f'example_{n}'] = html.p( Action( display_name=f'Example {n}: {example.description}', attrs__href=f'example_{n}', ), html.br(), ) return Fragment(children=children)
def example_links(examples): result = {} for i, example in enumerate(examples): n = i + 1 result[f'example_{n}'] = html.p( Action( display_name=f'Example {n}: {example.description}', attrs__href=f'example_{n}', ), html.br(), ) return result
class IndexPage(ExamplesPage): header = html.h1('Table examples') description = html.p('Some examples of iommi tables') all_fields = html.p( Action( display_name='Example with all available types of columns', attrs__href='all_columns', ), html.br(), after='example_6', ) class Meta: parts = example_links(examples)
def test_void_element_error(): with pytest.raises(AssertionError): assert html.br('foo').bind(request=None).__html__()
def test_render_empty_tag(): assert html.br().bind(parent=None).__html__() == '<br>'