Open norweis opened 3 years ago
The background for this is that I am currently evaluating the use of Accord for International Data Spaces IDS Data Usage Contracts, see https://internationaldataspaces.org/. Such a contract has many clauses which are activated by contract model variables when set, and the value of such a variable should be displayed within the the text for that clause.
Hi @norweis,
When you write an optional block:
{{#optional name}} Name: {{name}} {{/optional}}
This changes what variables are in scope for the content of that block:
// here `name` is in scope
{{#optional name}} /* here the _content_ of `name` is in scope /* {{/optional}}
So in the case where name
is an atomic type you can use the special variable {{this}}
which should contain the name:
{{#optional name}} Name: {{this}} {{/optional}}
For a complex type though you would most likely write something like this:
{{#optional name}} Name: {{firstName}} {{lastName}} {{/optional}}
Assuming name
is something like:
concept Person {
...
o Name name
...
}
concept Name {
o String firstName
o String lastName
}
Thank you. It works. But it is not documented.
A small error remains: Unknown property: name File text/grammar.tem.md line -1 column -1": It should report the correct line, column of the occurence of name, and possibly the hint : do you mean {{this}}
This issue isn't about template studio. Moving it to Cicero, more relevant.
In the Contract Grammar field, variables within #optional body are reported as unknown. E.g. (with "String name optional" in a model), the following reports: "Unknown property: name File text/grammar.tem.md line -1 column -1":
No variables are evaluated within the #optional Body.
Expected Behavior
In https://docs.accordproject.org/docs/markup-templatemark.html#optional-blocks a similar sample is used, but it does not work. Expected behavior is that if name is set in ContractData to value x, then Name: x should be displayed.
Current Behavior
False error message: "Unknown property: name File text/grammar.tem.md line -1 column -1". It also contains wrong line and column.
Steps to Reproduce
Context (Environment)
It occurs in any context (Browser, OS, ...) in latest Accord Studio.