The following type-checks fine:
{ Page.Default with
Body =
[
P [Text "HELLO"]
P [Text "HELLO"]
]
}
Here P is IntelliFactory.Html.Tags.P that is the server-side P. This
will generate <p> tags in the HTML directly.
The system will NOT allow you to include client-side P in the Body,
and for good reason: doing that would interleave client and
server-side code without giving the compiler any chance to unravel
them. If you are generating client-side dynamic code, it has to pass
through the control boundary:
{ Page.Default with
Body =
[
P [MyControl()]
]
}
Where MyControl is an IPagelet; MyControl constructor is called on the
server side, the object serialized, passed to the page, de-serialized
in JavaScript on the client-side, and its body constructed with DOM.
In the HTML source all you see is a placeholder under <p>.
Hope this helps.
Thanks,
Anton
--
Kind Regards,
Anton Tayanovskyy
WebSharper™ - type-safe JavaScript in F#
http://intellifactory.com
Use:
{ Page.Default with
Body =
[
Tags.I [Text "HELLO"]
Tags.B [Text "HELLO"]
]
}
Do not use Control types if you want to generate server-side HTML.
Yes, Control types are limited to generating a single DOM node.
Thanks,
Anton
--
--A
--
https://gist.github.com/a376b5b2d09d99b1637e
Is it clear why it is impossible to include client-side HTML elements
within server-side HTML elements or do I have to elaborate more?
--A
--
Please make sure you understand this: using offline HTML sitelets in
no way eliminates the distinction between server-side and client-side.
Maybe it might be better called static vs dynamic.
IntelliFactory.Html.* tags generate HTML statically, before the
browser starts - during compilation, in fact - for offline sitelets.
IntelliFactory.WebSharper.Html.* tags generate DOM nodes in the
browser and therefore support events and other dynamic features. These
cannot be mixed, except through the Control indirection I described
above.
Thanks,
--A
--