In cwrap, you can embed JavaScript inside JSON using {‎{}‎}. This allows for dynamic values and transformations during development, making JSON more flexible and interactive. Here are some examples of embedded JavaScript in JSON:

{
  "element": "h2",
  "style": "color: white; margin: 0; text-align: center; text-transform: uppercase;",
  "text": "{‎{return 'Some text';}‎}"
}
{
  "element": "h2",
  "style": "color: white; margin: 0; text-align: center; text-transform: uppercase;",
  "text": "{‎{const part1 = 'Some'; const part2 = 'Text'; return [part1, part2].join(' ');}‎}"
}
{
  "element": "h2",
  "style": "color: white; margin: 0; text-align: center; text-transform: uppercase;",
  "text": "{‎{return new Date().toLocaleDateString();}‎}"
}
{
  "element": "h2",
  "style": "color: white; margin: 0; text-align: center; text-transform: uppercase;",
  "text": "{‎{const amount = 1234.56; return amount.toLocaleString('en-US', { style: 'currency', currency: 'USD' });}‎}"
}

Another very powerful feature is triple brackets {‎{‎{}‎}‎}, which replaces the entire key-value pair with content, allowing almost unlimited object shaping DOM with JavaScript. Use with caution!

"placeholder": "{‎{‎{ return { "routes": cwrapContext.get('documentRoutes') }; }‎}‎}",