On Wed, Dec 16, 2009 at 11:55 AM, Ross Mellgren <[email protected]> wrote:
> I was diagnosing some incorrect HTML in our application using Lift,
> and I found a strange behavior of head merging (I assume) when you
> emit a <head> tag into a <head> tag from the snippet. The code speaks
> better than I do about this:
>
> ...
> object Dialog extends DispatchSnippet {
> val standardDialogOptions: JsObj = JsObj(
> "autoOpen" -> false,
> "bgiframe" -> true,
> "modal" -> true,
> "resizable" -> false
> )
>
> val dispatch: DispatchIt = {
> case "head" => renderHead
> case "render" => render
> }
>
> def renderHead(ns: NodeSeq): NodeSeq =
> <head>{ Script { JsCrVar("pxStandardDialogOptions",
> Dialog.standardDialogOptions) } }</head>
> ...
> }
>
>
> LiftRules.snippetDispatch.append {
> ...
> case "Dialog" => Dialog
> ...
> }
>
>
> <lift:surround with="default" at="content">
> <head>
> <title>Email Editor</title>
> <lift:Dialog.head />
> </head>
> </lift:surround>
>
>
> I agree I'm doing the wrong thing here -- the <lift:Dialog.head /> tag
> rightly should be outside of the head block, or the snippet should not
> emit <head>. However, the resulting behavior is funny (certainly more
> funny than I'd expect):
>
>
> <html xmlns:lift="http://liftweb.net/" xmlns="http://www.w3.org/1999/xhtml
> ">
> <head>
> ...
> <title>Email Editor</title>
>
>
> <script type="text/javascript">
> // <![CDATA[
> var pxStandardDialogOptions = {"autoOpen": false, "bgiframe": true,
> "modal": true, "resizable": false};
> // ]]>
> </script>
>
>
> <head><script type="text/javascript">
> // <![CDATA[
> var pxStandardDialogOptions = {"autoOpen": false, "bgiframe": true,
> "modal": true, "resizable": false};
> // ]]>
> </script></head>
>
>
> </head>
> ...
> </html>
>
>
> Ideally I'd like this to "just work" so that it doesn't matter
> precisely where the snippet is called, though it would be some special
> magic just to work around an erroneous case. But, the behavior that
> does happen seems odd, duplicating the markup inside the <head>?
>
> Should I file a bug? Just smile and nod?
>
If we had to recursively check all the <head> tags for <head> tags, that
would significantly increase the overhead of the rewrite phase. I would
suggest using the new Helpers.stripHead() call to remove <head> tags from
stuff you already know is in a <head> tag.
>
> -Ross
>
>
>
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<liftweb%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en.
>
>
>
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics
--
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en.