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

Better support for repeated model bindings in template #4

Closed
dselman opened this issue Nov 21, 2017 · 1 comment
Closed

Better support for repeated model bindings in template #4

dselman opened this issue Nov 21, 2017 · 1 comment

Comments

@dselman
Copy link
Contributor

dselman commented Nov 21, 2017

It is common for templates to include multiple references to the same template model property. At the moment the first reference is used to bind to the model, all others are ignored. We should at least validate that all references are equivalent and flag an error for inconsistent bindings.

See the code here:
https://github.com/accordproject/cicero/blob/master/packages/cicero-core/lib/template.js#L304

@jeromesimeon
Copy link
Member

This issue is fixed using the new parser infrastructure. Here is an example:

bash-3.2$ cat text/sample.md 
## Acceptance of Delivery.

"Party A" will be deemed to have completed its delivery obligations
if in "Party B"'s opinion, the "Widgets" satisfies the
Acceptance Criteria, and "Party B" notifies "Party A" in writing
that it is accepting the "Widgets".

## Inspection and Notice.

"Party B" will have 10 Business Days to inspect and
evaluate the "Widgets" on the delivery date before notifying
"Party A" that it is either accepting or rejecting the
"Widgets".

## Acceptance Criteria.

The "Acceptance Criteria" are the specifications the "Widgets"
must meet for the "Party A" to comply with its requirements and
obligations under this agreement, detailed in "Attachment X", attached
bash-3.2$ ~/git/cicero/packages/cicero-cli/index.js parse 
8:59:18 AM - info: Using current directory as template folder
8:59:18 AM - info: Loading a default text/sample.md file.
8:59:20 AM - info:
{
  "$class": "org.accordproject.acceptanceofdelivery.AcceptanceOfDeliveryClause",
  "shipper": "resource:org.accordproject.organization.Organization#Party%20A",
  "receiver": "resource:org.accordproject.organization.Organization#Party%20B",
  "deliverable": "Widgets",
  "businessDays": 10,
  "attachment": "Attachment X",
  "clauseId": "f4ecdf18-60ef-4758-aace-50b9feed7f2e"
}
bash-3.2$ cat text/sample.md 
## Acceptance of Delivery.

"Party XXX" will be deemed to have completed its delivery obligations
if in "Party B"'s opinion, the "Widgets" satisfies the
Acceptance Criteria, and "Party B" notifies "Party A" in writing
that it is accepting the "Widgets".

## Inspection and Notice.

"Party B" will have 10 Business Days to inspect and
evaluate the "Widgets" on the delivery date before notifying
"Party A" that it is either accepting or rejecting the
"Widgets".

## Acceptance Criteria.

The "Acceptance Criteria" are the specifications the "Widgets"
must meet for the "Party A" to comply with its requirements and
obligations under this agreement, detailed in "Attachment X", attached
bash-3.2$ ~/git/cicero/packages/cicero-cli/index.js parse 
8:59:42 AM - info: Using current directory as template folder
8:59:42 AM - info: Loading a default text/sample.md file.
8:59:45 AM - error: Inconsistent values for variable shipper: Party XXX and Party A
Error: Inconsistent values for variable shipper: Party XXX and Party A
    at mkCompoundVariable (/Users/jeromesimeon/git/cicero/node_modules/@accordproject/markdown-template/lib/combinators.js:79:23)
    at mkClause (/Users/jeromesimeon/git/cicero/node_modules/@accordproject/markdown-template/lib/combinators.js:143:12)
    at /Users/jeromesimeon/git/cicero/node_modules/@accordproject/markdown-template/lib/combinators.js:340:16
    at Parsimmon._ (/Users/jeromesimeon/git/cicero/node_modules/parsimmon/src/parsimmon.js:989:51)
    at Parsimmon._ (/Users/jeromesimeon/git/cicero/node_modules/parsimmon/src/parsimmon.js:685:40)
    at Parsimmon._ (/Users/jeromesimeon/git/cicero/node_modules/parsimmon/src/parsimmon.js:985:23)
    at Parsimmon._ (/Users/jeromesimeon/git/cicero/node_modules/parsimmon/src/parsimmon.js:985:23)
    at Parsimmon.<anonymous> (/Users/jeromesimeon/git/cicero/node_modules/parsimmon/src/parsimmon.js:1252:19)
    at Parsimmon._ (/Users/jeromesimeon/git/cicero/node_modules/parsimmon/src/parsimmon.js:685:40)
    at Parsimmon._ (/Users/jeromesimeon/git/cicero/node_modules/parsimmon/src/parsimmon.js:985:23)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants