class Heading:
    person: str
    name: Annotated[str, Context(), Attr('name')]
    greeting: Annotated[str, Get(Settings), Attr('greeting')]

    def __call__(self):
        return html('''<h1>{self.greeting} {self.person}, {self.name}</h1>''')
 def target(
     customer_name: Annotated[
         str,
         Context(),
         Attr('name'),
     ],
 ):
     return customer_name
Esempio n. 3
0
def test_context(regular_container):
    pipeline = (Context(), )
    result = process_pipeline(
        regular_container,
        pipeline,
        start=View,
    )
    assert result == regular_container.context
Esempio n. 4
0
class View:
    customer_name: Annotated[str, Context(), Attr('name'), ]

    @property
    def name(self):
        return f'Hello {self.customer_name}'
Esempio n. 5
0
class FrenchView:
    customer_name: Annotated[str, Context(), Attr('name'), ]

    @property
    def name(self):
        return f'Bonjour {self.customer_name}'
Esempio n. 6
0
class Greeting:
    name: Annotated[str, Context(), Attr('name')]

    def __call__(self):
        return html('<h1>Hello {self.name}</h1>')
Esempio n. 7
0
class SecondHeading:
    person: str
    name: Annotated[str, Context(), Attr('name')]
    greeting: Annotated[str, Get(Settings), Attr('greeting')]
    class Target:
        customer_name: Annotated[str, Context(), Attr('name'), ]

        def __call__(self):
            return self.customer_name
Esempio n. 9
0
class FrenchGreeting:
    name: Annotated[str, Context(), Attr('name')]

    def __call__(self):
        return html('<h1>Bonjour {self.name}</h1>')
Esempio n. 10
0
class DummyView(View):
    context_title: Annotated[DummyContext, Context(), Attr('title')]
    resource_title: Annotated[DummyContext, Get(Resource, attr='title')]

    def __call__(self) -> VDOM:
        return html('<div>Hello {self.context_title} from {self.resource_title}</div>')
Esempio n. 11
0
 class Heading:
     title: Annotated[
         str,
         Context(),
         Attr('name'),
     ]
Esempio n. 12
0
 class Heading:
     customer: Annotated[
         Customer,
         Context(),
     ]
Esempio n. 13
0
class ContextView:
    name: Annotated[str, Context(), Attr('name')]

    def __call__(self) -> str:
        return html('<div>Hello Customer</div>')