RE: Delimiters for String Templates (the ultimate Bike Shed!)

For anyone following this discussion, here is the syntax we adopted today:

6. ``[   ]``, `{ }`

Here are the examples we discussed for the earlier proposals.  I think we chose well.

Jonathan

First a function that returns text:

declare function local:prize-message($a) as xs:string
{
``[Hello `{$a.name}`
You have just won `{$a.value}` dollars!
`{ 
   if ($a.in_ca) 
   then ``[Well, `{$a.taxed_value}` dollars, after taxes.]``
   else ""
}`]``
}

Here's what it looks like if we produce HTML instead of text:

declare function local:prize-message($a) as xs:string
{
``[
  <div>
    <h1>Hello `{$a.name}`</h1>
    <p>You have just won `{$a.value}` dollars!</p>
    `{ 
      if ($a.in_ca) 
      then ``[ <p>Well, `{$a.taxed_value}` dollars, after taxes.</p> ]``
      else ""
    }`
  </div>
]``
}

Here's what it looks like if we produce JSON:

declare function local:prize-message($a) as xs:string
{
``[
 { 
     "greetings" : "Hello!",
     "value" : $a.value
     `{
      if ($a.in_ca) 
      then 
``[, 
    "taxed_value", `{ $a.taxed_value }`
]``  
      else ""  
     }`
 }
]`` 
} 


Received on Tuesday, 29 September 2015 20:37:24 UTC