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

{{#optional}} variables do not render in 'draft' when --unquoteVariables flag present. #290

Closed
martinhalford opened this issue Aug 18, 2020 · 3 comments
Assignees

Comments

@martinhalford
Copy link
Member

Describe the bug
For template models using {{#optional}} variables, an exception Cannot read property 'replace' of undefined is thrown during draft command if --unquoteVariables flag is present.

To Reproduce
Consider the following template archive.

empty-contract-cta.zip

model.cto

namespace org.accordproject.empty

import org.accordproject.cicero.contract.* from https://models.accordproject.org/cicero/contract.cto
import org.accordproject.cicero.runtime.* from https://models.accordproject.org/cicero/runtime.cto

// Template model
asset EmptyContract extends AccordContract {
    o Boolean yesNoFlag optional
}

// Request
transaction EmptyRequest extends Request {
}

// Response
transaction EmptyResponse extends Response {
}

grammar.med.tm

{{#optional yesNoFlag}}The yesNoFlag is {{this}}!{{/optional}}

data.json

{
  "$class": "org.accordproject.empty.EmptyContract",
  "yesNoFlag": true,
  "contractId": "31b2897f-308c-42e1-9d71-1b50f33e57bf"
}

Run the draft command

cicero draft --template . --data ./data.json --output ./text/sample.md

Executes correctly! :-)

11:07:50 PM - info: Creating file: ./text/sample.md
11:07:50 PM - info: The yesNoFlag is true!

Try the same command with --unquoteVariables set...

cicero draft --template . --data ./data.json --output ./text/sample.md --unquoteVariables

Returns the following error.

11:11:22 PM - error: Cannot read property 'replace' of undefined

Additional context
Cicero version 0.21.3

@jeromesimeon jeromesimeon self-assigned this Aug 22, 2020
@jeromesimeon
Copy link
Member

Can be reproduced directly with the markdown-transform:

bash-3.2$ ~/git/markdown-transform/packages/markdown-cli/index.js transform --from data --via ciceromark_unquoted --to markdown_cicero --template text/grammar.tem.md --model model/model.cto --input data.json --contract 
11:36:49 AM - error: Cannot read property 'replace' of undefined

@jeromesimeon
Copy link
Member

Fixed in #297
Test with that fix:

bash-3.2$ ~/git/markdown-transform/packages/markdown-cli/index.js transform --from data --via ciceromark_unquoted --to markdown_cicero --template text/grammar.tem.md --model model/model.cto --input data.json --contract 
12:02:32 PM - info: 
The yesNoFlag is true!

@jeromesimeon
Copy link
Member

Closing. Please reopen (or open a new issue) if any further problem.

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

No branches or pull requests

2 participants