Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic blocks and meta tags filtering #251

Merged
merged 12 commits into from
Oct 25, 2024
Merged

Dynamic blocks and meta tags filtering #251

merged 12 commits into from
Oct 25, 2024

Conversation

Andrew-Morozko
Copy link
Contributor

@Andrew-Morozko Andrew-Morozko commented Oct 15, 2024

Resolves #142

Deviations from the spec:

dynamic is not an attribute on a block, but a container block:

document "test-doc" {
	dynamic {
		items = ["a", "b", "c"]
		content text {
			value = "{{.vars.dynamic_item_index}}: {{.vars.dynamic_item}}"
		}
	}
}

dynamic_condition is dropped, content blocks and sections can be conditionally included by using is_included attribute.

There were a lot of corner cases in implementing this, @traut please check out the tests file and make sure that this is expected behaviour.

Dynamic blocks can contain multiple section and content blocks and can be contained by document and section blocks. They are transparently replaced by the children they're instantiating.

Resolves #99

Deviations from the spec:
I named CLI argument in plural (--with-meta-tags)

This was linked to issues Oct 15, 2024
@Andrew-Morozko Andrew-Morozko requested a review from traut October 15, 2024 02:43
@traut
Copy link
Member

traut commented Oct 16, 2024

@Andrew-Morozko awesome work here, and that's a great unit-test coverage, thank you! All of the behaviours there make sense to me.

One question I had -- what is the order of evaluation when both items and condition are defined (like here)? Maybe having it as another test case, that combines multi-item items and a condition, would make sense too.

@Andrew-Morozko
Copy link
Contributor Author

what is the order of evaluation when both items and condition

In spec, condition determines whether or not dynamic item is shown at all, so it is always evaluated first.

On the second thought, if it would be evaluated per dynamic item it would be a bit more more powerful, allowing to selectively hide only some dynamic items. Currently this could be done with by filtering within query_jq.

Although if it evaluated after items, it would loose access to parent's dynamic_var_val... Perhaps they should be evaluated in the order of their definition, allowing user to choose? What are your thoughts?

Copy link
Contributor

@anasmuhmd anasmuhmd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thank you @Andrew-Morozko

@Andrew-Morozko Andrew-Morozko force-pushed the dynamic-blocks branch 4 times, most recently from ad0f6dc to 7d2dc05 Compare October 21, 2024 03:19
@Andrew-Morozko Andrew-Morozko merged commit 2f591ab into main Oct 25, 2024
18 of 22 checks passed
@Andrew-Morozko Andrew-Morozko deleted the dynamic-blocks branch October 25, 2024 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dynamic blocks Support content selection using meta tags
3 participants