Open traut opened 8 months ago
Shouldn't this be outside of the content block? Like using something like dynamic
block with a condition when to render content.
It is pretty close to the dynamic block concept (I'm still working on the issue for that), indeed! We need to figure out an unobstructed syntax here -- it would be too cumbersome for the template authors to wrap every content block into another dynamic block. It needs to be a small addition, not a syntax change. Maybe these in-block fields can be syntactic sugar implemented through the dynamic blocks in the logic.
with https://github.com/blackstork-io/fabric/issues/142 in mind, I think this issue still stands -- dynamic blocks are not well suitable for not-null checks
@traut What if we added a child block type for all content
blocks? Something like:
content table {
query = "..."
...
empty_result {
content text {
value = "Empty data!"
}
}
This would be a bit more flexible because we could specify any fallback content block.
that's neat, it's declarative and provides more options. To reduce the nest-iness, maybe it can be a content block with some flag, like
content table {
query = "..."
...
when_empty content text {
value = "Empty data!"
}
}
?
and we can use ref
as well:
content table {
query = "..."
...
when_empty content ref {
base = content.text.empty_data
}
}
still not great :) it's confusing -- is empty_result
/ when_empty
about the parent block or the nested block?
on_empty
? Could also extend in the future with fallbacks for errors on_error
.
oh, that's lovely.
content table {
query = "..."
...
on_empty content text {
value = "Empty data!"
}
}
content table {
query = "..."
...
on_empty content ref {
base = content.text.empty_data
}
}
would be ok, I think
moving this to draft since https://github.com/blackstork-io/fabric/issues/142 already can provide the functionality, even though in a bit wordy way
Background
https://github.com/blackstork-io/fabric/issues/142 introduces
dynamic
blocks. One typical pattern is to select which content to render based on the query result.Design
Implement syntactic sugar t
is unpacked into
Deliverables