from viewdom import html, render, use_context, Context

expected = '<h1>My Todos</h1><ul><li>Item: first</li></ul>'

# start-after
title = 'My Todos'
todos = ['first']


def Todo(label):
    prefix = use_context('prefix')
    return html('<li>{prefix}{label}</li>')


def TodoList(todos):
    return html('<ul>{[Todo(label) for label in todos]}</ul>')


result = render(html('''
  <{Context} prefix="Item: ">
      <h1>{title}</h1>
      <{TodoList} todos={todos} />
  <//>    
'''))
# '<h1>My Todos</h1><ul><li>Item: first</li></ul>'

[((200, 221), 'viewdom.use_context', 'use_context', (['"""prefix"""'], {}), "('prefix')\n", (211, 221), False, 'from viewdom import html, render, use_context, Context\n'), ((233, 265), 'viewdom.html', 'html', (['"""<li>{prefix}{label}</li>"""'], {}), "('<li>{prefix}{label}</li>')\n", (237, 265), False, 'from viewdom import html, render, use_context, Context\n'), ((300, 351), 'viewdom.html', 'html', (['"""<ul>{[Todo(label) for label in todos]}</ul>"""'], {}), "('<ul>{[Todo(label) for label in todos]}</ul>')\n", (304, 351), False, 'from viewdom import html, render, use_context, Context\n'), ((370, 492), 'viewdom.html', 'html', (['"""\n  <{Context} prefix="Item: ">\n      <h1>{title}</h1>\n      <{TodoList} todos={todos} />\n  <//>    \n"""'], {}), '(\n    """\n  <{Context} prefix="Item: ">\n      <h1>{title}</h1>\n      <{TodoList} todos={todos} />\n  <//>    \n"""\n    )\n', (374, 492), False, 'from viewdom import html, render, use_context, Context\n')]