cbmarcum / skeletal

A simple project creation tool that uses packaged templates
Apache License 2.0
17 stars 3 forks source link

document using a dollar property for Groovy classes #22

Open cbmarcum opened 1 year ago

cbmarcum commented 1 year ago

When using a template for a Groovy classes you may have a GString with a Variable ${variable} inside a GString. When the template is processed it will throw an error since it expects a property to replace it with. One solution is to to try to escape the characters but the solution I usually use it to make a variable for the $. Example _result:

println("${operand1} + ${operand2} = ${result}")

To get this... In lazybones.groovy

props.dollar='$'

In the template:

println("${dollar}{operand1} + ${dollar}{operand2} = ${dollar}{result}")