Replies: 2 comments 1 reply
-
component FancyButton:
`template`:
tButton:
slot
...
builtHtml:
component FancyButton:
"hello"
component FancyButton:
"world" |
Beta Was this translation helpful? Give feedback.
0 replies
-
slots allow this. You can also use it like this component Button:
flat: bool = true
`template`:
if self.flat:
tButton:
slot
else:
tButton(...):
slot |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It would be helpful in general if components placement in the DSL worked as if the component were an extended tag.
For instance, components might be some kind of complicated flex-container, or a fancy button with some of its styling dependent on the state of some
remember
ed vars.Then might want to say
In analogy with
to set the text child of the button component. Currently it does not work this way: the "fancyText" does not bind as child of the button. I predict this logic would be hard to code in a fully automated way since there are a couple different cases. Karax handles this in part with a distinction between
VNode
s, which are the actual elements of the VDOM, andVComponent
s, which render by producing aVNode
which renders the exact same way as other literalVNode
s.But perhaps the template macro in this framework could be extended to explicitly declare where children should attach when the component is placed this way in some other template or route. Maybe something in line with how the nim
{.importjs .}
pragma works.. For example, maybe:to apply some kind of fancy processing to the first child, but leave the @click part that comes after untouched.
Beta Was this translation helpful? Give feedback.
All reactions