Giter VIP home page Giter VIP logo

Comments (4)

jeromesimeon avatar jeromesimeon commented on July 20, 2024

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.

from cicero.

jeromesimeon avatar jeromesimeon commented on July 20, 2024

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.

from cicero.

jeromesimeon avatar jeromesimeon commented on July 20, 2024

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$ 

from cicero.

jeromesimeon avatar jeromesimeon commented on July 20, 2024

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

from cicero.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.