[Ur] Simple XML Templating Problem

maasha at gmail.com maasha at gmail.com
Thu Oct 2 16:49:34 EDT 2014


You where pretty spot on it was just that the convention for pairs is
different than what you were using and I have included the modified code
below.  Let me know if it works for you.  Sorry for my bad grammar in my
previous message, hopefully my emails help.

happy hacking

------------------------------------------------------------------------------------------------------------------------

style footer
style header

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

fun header_tmpl () : xbody = <xml><div class="header">he\
ader</div></xml>
fun footer_tmpl () : xbody = <xml><div class="footer">fo\
oter</div></xml>

fun body_tmpl (body_xml:xbody) =
    <xml><body>
    {header_tmpl ()}
    {body_xml}
    {footer_tmpl ()}
    </body></xml>

(* 1. changed the types to the convention
      that works with pairs.
*)
fun page ((title,body) : (string * xbody)) =
    <xml>
    {head_tmpl title}
    {body_tmpl body}
    </xml>

(* 2. changed the calling convention to
      to work with the new definition *)
fun main () : transaction page =
    return (page ("BlogMain",<xml/>))


-------------- Another alternative would be
----------------------------------

(* 1. changed the types to the convention
      that works with two arguments.
*)
fun page (title : string) (body : xbody) =
    <xml>
    {head_tmpl title}
    {body_tmpl body}
    </xml>

(* 2. changed the calling convention to
      to work with the new definition *)
fun main () : transaction page =
    return (page "BlogMain" <xml/>)




More information about the Ur mailing list