-
Notifications
You must be signed in to change notification settings - Fork 2
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
Local context for content plugins invocation #17
Comments
I have a couple of concerns: right now all inter-block linking (config/ref) is done exclusively via names, but here the second Perhaps we should stick to the named references, it would look something like this: document "test-document" {
meta {
name = "Test Document Template"
tags = ["tag-a", "tag-b"]
}
content text "my_query" {
query = .document.meta.name
text = "Template name is is {{ .query_result }}"
}
content text {
query = .document.content["my_query"].result
test = "Referenced block result is \"{{ .query_result }}\""
}
} The second issue is references to yet-unexecuted blocks, like this: document "test-document" {
meta {
name = "Test Document Template"
tags = ["tag-a", "tag-b"]
}
content text {
query = .document.content["my_query"].result
test = "Referenced block result is \"{{ .query_result }}\""
}
content text "my_query" {
query = .document.meta.name
text = "Template name is is {{ .query_result }}"
}
} I assume for v0.1 we'll just forbid it, but the decision on whether we would eventually support these kinds of references should be made before the refactoring becomes too expensive. |
Good points! I agree the proposed design could be better -- I'm open to ideas! Having that document structure available for inspection ith queries allows us to build meta-blocks -- the blocks that use the document body as a data source. That data structure does not have to align to the one the business logic uses, it can be a serialization / simplification - it just needs to be easily queriable with My example with access-by-index through
Until now, we didn't consider referencing content inside the document. The references we worked with were against the blocks defined on the root level. Indeed, referencing inside the document is a completely different case -- on the path to the target block there might be anonymous parent blocks!
I thought we can fix this by adding an explicit I do not have a good idea on the |
Background
Content plugins require the local context, in addition to invocation parameters, for execution. In addition to the data fetched from data plugins, the local context must contain the body of the template and the results of previous executions -- this will allow us to create meta content blocks -- the blocks that query the template / other blocks instead of just data.
Design
data
-- a map with the data returned bydata
pluginsdocument
-- a JSON-style map of the currentdocument
templatecontent
blocks contain aresult
field with the result of the execution of the blockcontent
plugin execution steps:query
root field that contains a value ofquery
attribute from the block definitionquery_result
-- a result of JQ query fromquery
attribute applied to the initial local context (withdata
anddocument
top fields)For example, we should be able to perform these queries:
The text was updated successfully, but these errors were encountered: