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

Should template language allow parameter within optional text in clauses #17

Closed
jeromesimeon opened this issue Dec 20, 2017 · 4 comments
Labels

Comments

@jeromesimeon
Copy link
Member

Is there a way to indicate parameters within optional text in clauses? For instance:

In case of delayed delivery [{" except for Force Majeure cases in the 7 DAYS before the delivery date,":? forceMajeure}]

Is it be possible for the period 7 DAYS to be a parameter of the template instead of a fixed time?

@jeromesimeon
Copy link
Member Author

This could be best handled by adding a notion of optional block which would correspond to the optional type in Concerto. An example could look as follows:
CTO Model:

concept ForceMajeure {
  o Duration window
}
concept TemplateModel {
  o ForceMajeure forceMajeure optional
}

With the following block:

In case of delayed delivery {{#optional forceMajeure}} except for Force Majeure cases in the {{window}} before the delivery date,{{/optional}}

Note that the new notion of blocks and scoping make this very natural, and allows the template to distinguish between: presence or absence of the optional field, and if present to indicate variables inside the text.

@jeromesimeon
Copy link
Member Author

This feature did not make it into 0.20 but should be relatively easy to add now that we have the block syntax support, and could be considered for 0.21.

@jeromesimeon
Copy link
Member Author

jeromesimeon commented Jul 3, 2020

This is now supported in the upcoming new parser:

bash-3.2$ more grammar.tem.md 
This is a contract between {{seller}} and {{buyer}} for the amount of {{amount}} {{currency}}.{{#optional forceMajeure}}
This applies even in the presence of force majeure with a discount of {{rate}}%.{{/optional}}
bash-3.2$ more sample.md 
This is a contract between "Steve" and "Betty" for the amount of 3131.0 EUR.
This applies even in the presence of force majeure with a discount of 10.5%.
bash-3.2$ more model.cto 
namespace org.test

import org.accordproject.cicero.contract.* from https://models.accordproject.org/cicero/contract.cto
import org.accordproject.money.CurrencyCode from https://models.accordproject.org/[email protected]

/**
 * The template model
 */
concept DiscountRate {
  o Double rate
}
asset MyClause extends AccordClause {
  o String seller
  o String buyer
  o Double amount
  o CurrencyCode currency
  o DiscountRate forceMajeure optional
}
bash-3.2$ ~/git/markdown-transform/packages/markdown-cli/index.js transform --to data --grammar grammar.tem.md --ctoFiles model.cto --input sample.md 
5:17:14 PM - info:
{
  "$class": "org.test.MyClause",
  "seller": "Steve",
  "buyer": "Betty",
  "amount": 3131,
  "currency": "EUR",
  "forceMajeure": {
    "$class": "org.test.DiscountRate",
    "rate": 10.5
  },
  "clauseId": "049f70d6-feff-4c11-99df-d43076d3dff3"
}
bash-3.2$ 

@jeromesimeon
Copy link
Member Author

This issue has been finally resolved with the release of cicero 0.21.

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

No branches or pull requests

1 participant