snowindy/scriptlet4docx

Gracefully use null replacements in case of missing property in template params

RushPVA opened this issue · 4 comments

if i have ${agencyName} in my template and haven't key "agencyName" in params map, i ll get next exception:
: [http-thread-pool-7067(2)] | ERROR | Cannot process template: [3f8a977f-69e8-4947-8558-9859a35e977c${__docxTemplaterInstance.replaceIfNull(agencyName)}4cdce23e-9c89-4e70-894d-fb2d099a2695${__docxTemplaterInstance.replaceIfNull(applicant)}9a93a81f-817d-4542-9ab6-feeb6f6c00e5${__docxTemplaterInstance.replaceIfNull(dulSeries)}98917caf-49ae-4a91-9124-efc2921fc894${__docxTemplaterInstance.replaceIfNull(dulNumber)}05a5f06b-6fb5-4b30-b840-4250dbc5af8a${__docxTemplaterInstance.replaceIfNull(dulIssuedBy)}b3189a1a-3463-473d-a1e4-44e2b9588a16${__docxTemplaterInstance.replaceIfNull("serviceName")}626a17ed-1912-44fb-ac12-b86c50e5efc0].
groovy.lang.MissingPropertyException: No such property: agencyName for class: groovy.tmp.templates.GStringTemplateScript1
[12:38:45] Куксо Илья: 17.11.2015 12:34:14.276 | [http-thread-pool-7067(2)] | ERROR | java.lang.RuntimeException: java.lang.RuntimeException: groovy.lang.MissingPropertyException: No such property: agencyName for class: groovy.tmp.templates.GStringTemplateScript1
groovy.lang.MissingPropertyException: No such property: agencyName for class: groovy.tmp.templates.GStringTemplateScript1

What do you expect to see?

i expect null replacement defined in "setNullReplacement" method

Fixed in 0.8.4. It will soon appear in Maven Central.

Good job. thank you.