Skip to content

Instantly share code, notes, and snippets.

@ppazos
Created January 17, 2026 17:42
Show Gist options
  • Select an option

  • Save ppazos/a1d6dc0991009fd54115cc11336a8ca9 to your computer and use it in GitHub Desktop.

Select an option

Save ppazos/a1d6dc0991009fd54115cc11336a8ca9 to your computer and use it in GitHub Desktop.
In Grails, the Goovy variables in GSP can be accessed by ${var} but that's also how JS string literals access variables, giving an error in GSP
// Here Groovy prints the '$', leaving it for the JS to evaluate the variable correctly on the client side.
let btnAuthorize = `<a href="merge/${'$'}{record.id}/authorize" class="btn btn-primary">Authorize</a>`;
// This will fail if record is a JS object
let btnAuthorize = `<a href="merge/${record.id}/authorize" class="btn btn-primary">Authorize</a>`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment