[Ur] Simple XML Templating Problem

Sergey Mironov grrwlf at gmail.com
Thu Oct 2 15:56:08 EDT 2014


2014-10-02 23:33 GMT+04:00 Burton Samograd <burton.samograd at gmail.com>:
> Still no luck:
>
> fun head_template (_title:string) =
>     return <xml><head><title>{[_title]}</title></head></xml>
>
> fun main () = return <xml>
>     {head_template "Blog Main"}
>     <body>
>     </body>
>     </xml>

The error is caused by the type mismatch. <xml>{f x}</xml> works only
for pure functions f. Pure functions usually don't mention
'transaction' in their type signatures, nor they use 'return' keyword
in their bodies. Your code snippet have two problems: 1) unspecified
type for [main] and 2) 'return' keyword in [head_template] conflicting
with <xml>{..}</xml> call. Try this code instead:

 fun head_template (_title:string) =
     <xml><head><title>{[_title]}</title></head></xml>

 fun main () : transaction page = return <xml>
     {head_template "Blog Main"}
     <body>
     </body>
     </xml>

Regards,
Sergey



More information about the Ur mailing list