title: How to fix "Unexpected token $ in JSON" when using VelocityJS to parse VTL
body: <p>In order to write unit tests for my AppSync resolvers, I'm using the VelocityJS package to parse the VTL inside of my sam template. However, the VTL template isn't being fully parsed.</p>
  
  <p>The code works fine on AWS, it's the unit tests that are erroring.
  <a href="https://github.com/shepherdwind/velocity.js" rel="nofollow noreferrer">https://github.com/shepherdwind/velocity.js</a></p>
  
  <pre><code>#if($util.isNullOrBlank($ctx.result.themePreferences))
      #set($themePreverences = {})
      $util.qr($themePreverences.put("darkMode", "DEFAULT"))
      $util.qr($ctx.result.put("themePreferences", $themePreverences))
  #end
  $util.toJson($ctx.result)
  </code></pre>
  
  <p>When using <code>let result = Velocity.parse(template, ctx);</code> the result is the string <code>"$util.toJson($ctx.result)"</code> instead of the JSON value of <code>$ctx.result</code>.</p>
  
  <p>IE:</p>
  
  <pre><code>{ "themePreferences": { "darkMode": "DEFAULT" } }
  </code></pre>