title: Unable to get IntelliJ's (Velocity) Code Template to work correctly with conditional variable assignment
body: <p>I am attempting to improve a Scala Companion Object plus Case Class code generating template in IntelliJ 2021.3 (Build #IU-213.5744.223, built on November 27, 2021).</p>
  <p>I would like to allow the user to be able to leave some of the input parameters unspecified (empty) and then have the template generate sane defaults. This is because the generated code can then be refactored by the client to something more pertinent later.</p>
  <p>My question is this: Is there another way to approach achieving my goal than the way I show below using the Velocity #macro (which <a href="https://stackoverflow.com/questions/1119345/conditional-operator-in-velocity">I got from here</a>, and then doesn't appear to work anyway)?</p>
  <p>With the current approach using the #marco, when I invoke it...</p>
  <p>With:</p>
  <ol>
  <li>NAME = &quot;Longitude&quot;</li>
  <li>PROPERTY_1_VARIABLE = &quot;value&quot;</li>
  <li>PROPERTY_1_TYPE - &quot;Double&quot;</li>
  </ol>
  <p>The Scala code target:</p>
  <pre class="lang-scala prettyprint-override"><code>final case class Longitude(value: Double)
  </code></pre>
  <p>With:</p>
  <ol>
  <li>NAME = &quot;Longitude&quot;</li>
  <li>PROPERTY_1_VARIABLE = &quot;&quot;</li>
  <li>PROPERTY_1_TYPE - &quot;&quot;</li>
  </ol>
  <p>The Scala code target using defaults for 2 and 3:</p>
  <pre class="lang-scala prettyprint-override"><code>final case class Longitude(property1: Property1Type)
  </code></pre>
  <p>And here's my attempt to make it work with the IntelliJ (Velocity) Code Template:</p>
  <pre><code>#macro(condOp $check, $default)
    #if ($check == &quot;&quot;)
      $default
    #else
      $check
    #end
  #end
  
  #set (${PROPERTY_1_VARIABLE} = &quot;#condOp(${PROPERTY_1_VARIABLE}, 'property1')&quot;)
  #set (${PROPERTY_1_TYPE} = &quot;#condOp(${PROPERTY_1_TYPE}, 'Property1Type')&quot;)
  
  #if ((${PACKAGE_NAME} &amp;&amp; ${PACKAGE_NAME} != &quot;&quot;))package ${PACKAGE_NAME} #end
  
  final case class ${NAME} (${PROPERTY_1_VARIABLE}: ${PROPERTY_1_TYPE})
  </code></pre>
  <p>First, the IntelliJ popup box for entering the parameters correctly shows &quot;Name:&quot;. And then incorrectly shows &quot;default:&quot; and &quot;check&quot;. I have <a href="https://youtrack.jetbrains.com/issue/IDEA-287628" rel="nofollow noreferrer">submitted a ticket with Jetbrains for this IntelliJ issue</a>. Please vote for it, if you get a chance so it increases in priority.</p>
  <p>And then when the macro finishes executing (I provide the Name of &quot;LongLat&quot;, but leave the default and check parameters empty), I don't understand why I get the following gibberish.</p>
  <pre class="lang-scala prettyprint-override"><code>
  
  package org.public_domain
  
  ${PROPERTY_1_TYPE})
  </code></pre>
  <p>Any guidance on fixing my current Velocity Code Template script or suggest another way to effectively approach solving the problem would be deeply appreciated.</p>