Comments (10)
I've been reviewing the volume discount template and I think
supporting an arbitrary number of rows would require a couple of
extensions to the current template format.
One extension is the ability to specify a piece of repeating text
(which would correspond to an array in the corresponding
JSON). Another extension needed is the ability to describe alternative
texts.
One possiblity that addresses both requirements is to rely on a simple
kind of regular expressions. Here is a short proposal which suggests
some new markup to do that:
Markup for optional text with corresponding JSON field:
[?{myOptionalField} some text goes here]
Markup for repeated text with corresponding JSON field:
[+{myArrayField} some text that might be repeated one or more times goes here]
Markup for alternative texts:
[some left text goes here \| some right text goes here]
With those new constructs in mind, the decision table from the
volumediscount
template could be written as follows:
Volume-Based Card Acceptance Agreement [Abbreviated]
This Agreement is by and between Card, Inc., a New York corporation, and you, the Merchant. By accepting the Card, you agree to be bound by the Agreement.
Discount means an amount that we charge you for accepting the Card, which amount is: ...
| Annual Dollar Volume | Discount |
[+{discountRates}| [ Less than $[{volumeUpTo}] million \| [{volumeAbove}] million to [{volumeUpTo}] \| Greater than [{volumeAbove}] million] | [{rate}]% |]
_______________________ _____________________
Card, Inc. Merchant
Now if you parse the corresponding clause text with this template:
Volume-Based Card Acceptance Agreement [Abbreviated]
This Agreement is by and between Card, Inc., a New York corporation, and you, the Merchant. By accepting the Card, you agree to be bound by the Agreement.
Discount means an amount that we charge you for accepting the Card, which amount is: ...
| Annual Dollar Volume | Discount |
| Less than $1 million | 3.00% |
| $1 million to $10 million | 2.90% |
| Greater than $10 million | 2.80% |
It should succeed and return with the following JSON:
{
'discountRates' : [
{ 'volumeUpTo' : 1,
'rate' : 3.00 },
{ 'volumeUpTo' : 10,
'volumeAbove' : 1,
'rate' : 2.90 },
{ 'volumeAbove' : 10,
'rate' : 2.80 }
]
}
from cicero.
Attached is another example which is a fuel surcharge clause which is rather cumbersome as we have to define new model variables for each element in the table and we require a fixed number of rows in the table.
from cicero.
Another good example of this is in the volume discount template, which includes a decision table like construct.
from cicero.
Note that something along those lines would also address issue #16 and possibly #17.
from cicero.
Like it.
from cicero.
An example that uses arrays in the model.
from cicero.
Code that prevents using Arrays in the template model:
https://github.com/accordproject/cicero/blob/master/packages/cicero-core/src/template.js#L328
from cicero.
Current state is that you CAN use arrays in your models - but not the template model itself.
from cicero.
It would be interesting to support any arbitrary sequence of chars as separator in arrays.
For example, in a table like this one:
| DEAL | 16.00 | 15.90 | 15.65 | 14.75 | 13.20 |
' | ' is the delimiter.
And we can even go a step further by supporting Regex to be used as separators.
from cicero.
We now have support for lists using blocks (tied to Markdown lists), either as: {{#ulist}} ... {{/ulist}}
or {{#olist}} ... {{/olist}}
in version 0.20
. I'm closing. Reopen if you disagree! (Or open a new issue if new feature needed).
from cicero.
Related Issues (20)
- CICERO_PORT does not set Cicero Server port properly
- cicero verify does not report errors properly HOT 2
- Cicero-server not working offline: options are not passed to "Template.fromDirectory()" in "initTemplateInstance()" HOT 6
- Outdated Contributing.md Doc HOT 1
- Cicero-CLI: utcOffset and currentTime concurrent usage gives error HOT 6
- Cicero-core: Failing mocha tests
- Failed Curl Request in Cicero-server package HOT 2
- Cicero-core: Provide custom loadfilecontents and loadfilebuffer options in ``Template.fromDirectory()`` HOT 2
- Template archive .cta file imported on VS Code extension - Model and parse error
- cicero-server: Missing tmp-promise dependency
- Replacement expression language for TemplateMark HOT 1
- Cicero DRAFT error when executed against compressed .CTA archive templates. HOT 3
- Lerna Bootstrap no longer supported as of Lerna v7.0
- Some package.json attributes within Template archive need rethinking. HOT 1
- Archive command fails when model contains versioned imports.
- Extending Asset with Contract or Clause causes Archive error HOT 2
- CLI: `cicero get` command pulls in obsolete external models. HOT 2
- New name for `cicero` command line tool HOT 4
- CLI: Reimplement "draft" command HOT 1
- Add Support for Logic Files in TypeScript
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cicero.