Support state vars in pc.markdown
(#392)
This commit is contained in:
parent
450576bbee
commit
3f5ff53c88
@ -1,10 +1,11 @@
|
|||||||
"""Markdown component."""
|
"""Markdown component."""
|
||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
from typing import List
|
from typing import List, Union
|
||||||
|
|
||||||
|
from pynecone import utils
|
||||||
from pynecone.components.component import Component
|
from pynecone.components.component import Component
|
||||||
from pynecone.var import BaseVar
|
from pynecone.var import BaseVar, Var
|
||||||
|
|
||||||
|
|
||||||
class Markdown(Component):
|
class Markdown(Component):
|
||||||
@ -25,10 +26,14 @@ class Markdown(Component):
|
|||||||
Returns:
|
Returns:
|
||||||
The markdown component.
|
The markdown component.
|
||||||
"""
|
"""
|
||||||
assert (
|
assert len(children) == 1 and utils._isinstance(
|
||||||
len(children) == 1
|
children[0], Union[str, Var]
|
||||||
), "Markdown component must have exactly one child containing the markdown source."
|
), "Markdown component must have exactly one child containing the markdown source."
|
||||||
src = textwrap.dedent(children[0])
|
|
||||||
|
# Get the markdown source.
|
||||||
|
src = children[0]
|
||||||
|
if isinstance(src, str):
|
||||||
|
src = textwrap.dedent(src)
|
||||||
return super().create(src, **props)
|
return super().create(src, **props)
|
||||||
|
|
||||||
def _get_imports(self):
|
def _get_imports(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user