Using the <head> tag in HTML5 templates

85 views
Skip to first unread message

David Pollak

unread,
Dec 3, 2010, 9:22:39 AM12/3/10
to liftweb
Folks,

The HTML5 parser does not allow you to put a <head> tag anywhere except as the first tag under the <html> tag.  If you need a to use Lift's <head> tag merging feature (e.g., your template requires an additional script or style tag in the head), please use <lift:head>.

I'll update the wiki documentation on HTML5 with this information.

Thanks,

David

--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Blog: http://goodstuff.im
Surf the harmonics

Jeppe Nejsum Madsen

unread,
Jan 10, 2011, 5:36:12 AM1/10/11
to lif...@googlegroups.com
On Fri, Dec 3, 2010 at 3:22 PM, David Pollak
<feeder.of...@gmail.com> wrote:
> Folks,
>
> The HTML5 parser does not allow you to put a <head> tag anywhere except as
> the first tag under the <html> tag.  If you need a to use Lift's <head> tag
> merging feature (e.g., your template requires an additional script or style
> tag in the head), please use <lift:head>.
>
> I'll update the wiki documentation on HTML5 with this information.

Did this ever make it? I get an "Class Not Found" error with the
lift:head tag and I can't see any mention of it on the wiki or in the
builtin snippets...

/Jeppe

Peter Petersson

unread,
Jan 10, 2011, 5:49:59 AM1/10/11
to lif...@googlegroups.com, Jeppe Nejsum Madsen
Yes at least it was in RC6.
Usage is demonstrated a bit in to this Basic Lift training video
The video is available here http://vimeo.com/groups/75631
See "Basic Lift training video" thread above

regards
Peter Petersson

Peter Petersson

unread,
Jan 10, 2011, 5:58:42 AM1/10/11
to lif...@googlegroups.com
sry I just realized you are prob. a Lift dev and committer ... ignore my
comment ;)

On 2011-01-10 11:36, Jeppe Nejsum Madsen wrote:

Jeppe Nejsum Madsen

unread,
Jan 10, 2011, 7:17:42 AM1/10/11
to lif...@googlegroups.com
On Mon, Jan 10, 2011 at 11:58 AM, Peter Petersson
<peterss...@gmail.com> wrote:
> sry I just realized you are prob. a Lift dev and committer ... ignore my
> comment ;)

No problem, I appreciate your reply. Being a committer doesn't
necessarily mean I know everything about Lift :-)

Do you have an idea where in the video this is mentioned?

/Jeppe

Peter Petersson

unread,
Jan 10, 2011, 7:53:33 AM1/10/11
to lif...@googlegroups.com
ye about 01:41 into the video.
As I understand it the examples in the video is done with the html5
renderer but it seems the imp. has changed and you should use one or
more <head>....</head> blocks inside the body of your template ... it
will then be moved/added to the "real head" (the template head) during
rendering.

Best regards
Peter Petersson

Jeppe Nejsum Madsen

unread,
Jan 10, 2011, 9:36:37 AM1/10/11
to lif...@googlegroups.com
On Mon, Jan 10, 2011 at 1:53 PM, Peter Petersson
<peterss...@gmail.com> wrote:
> ye about 01:41 into the video.
> As I understand it the examples in the video is done with the html5 renderer
> but it seems the imp. has changed and you should use one or more
> <head>....</head> blocks inside the body of your template ... it will then
> be moved/added to the "real head" (the template head) during rendering.

Ok I'll have a look. But what you described seems to be the "old" style:

In template.html:

<sometag>
<head
</head
</sometag>

The head content of the template would be merged with the head content
from other templates, snippets etc. But when using the html5 parser,
it seems the above construct is not valid in a template (since head
needs to be directly below the html tag and there's not html element
in this template).

I think the proposed solution was in this case to use the <lift:head>
tag instead but, alas, this gives an error.

As a workaround it seems I can use a designer friendly template and
surround sometag with a valid html document & body.

/Jeppe

Jeppe Nejsum Madsen

unread,
Jan 10, 2011, 11:18:56 AM1/10/11
to lif...@googlegroups.com


Ok, found another post that mentioned the head_merge tag. This seems
to work, so I've updated the wiki to reflect this.

/Jeppe

Peter Petersson

unread,
Jan 10, 2011, 11:35:08 AM1/10/11
to lif...@googlegroups.com
Yes you better take a look cause I am very new to lift and do not know
if what I have been presented is a new or old way of doing things. Maybe
this example is in xhtml (but I do not think so), I would appreciate to
here what you find out.

Yes the example is like this

designer friendly html snippet
<body> <-- crome
:
<some tag> <-- actual content
:
<head>head content 1 script or what ever </head>
:
<head>head content 2 </head>
:
</some tag>
</body> <-- crome

so what you are saying is that needer <head> or of course <lift:head> is
not valid html5 inside the body and hens not useful in a designer
friendly html template. I have tried it out html5 and the page render
okey in firefox 3.6.13 type <head><title>test2</title></head> inside
the body dose not show up or make any rendering errors

best regards
Peter Petersson

David Pollak

unread,
Jan 10, 2011, 11:44:37 AM1/10/11
to lif...@googlegroups.com
The Html5 parser discards the <head> tags inside the body.  There are a bunch of other things that the Html5 parser does silently.  Sorry.

As Jeppe pointed out, <head_merge>....</head_merge> works.

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.

Peter Petersson

unread,
Jan 11, 2011, 7:37:35 AM1/11/11
to lif...@googlegroups.com, David Pollak
Sry David but can you clarify (still a bit confused ;) ), dose the "Basic Lift training video" switch between xhtml and html5 when demonstrating different aspects of lift ?
In the beginning of the video its clearly html5 so when you later demonstrates the Lift feature of placing <head>code block</head> (for the parser to move and merge) inside the html body (and not <lift:head> or <head_merge>) it is a xhtml example ? (or did I misunderstand you.)

regards
   Peter

David Pollak

unread,
Jan 11, 2011, 9:27:39 AM1/11/11
to liftweb
On Tue, Jan 11, 2011 at 4:37 AM, Peter Petersson <peterss...@gmail.com> wrote:
Sry David but can you clarify (still a bit confused ;) ), dose the "Basic Lift training video" switch between xhtml and html5 when demonstrating different aspects of lift ?

The materials for the training are available at http://tunaforcats.com/lift_training.tgz

Please look to see if each example is HTML5 or XHTML.
 
In the beginning of the video its clearly html5 so when you later demonstrates the Lift feature of placing <head>code block</head> (for the parser to move and merge) inside the html body (and not <lift:head> or <head_merge>) it is a xhtml example ? (or did I misunderstand you.)

Yeah... probably.
 

Peter Petersson

unread,
Jan 11, 2011, 10:02:15 AM1/11/11
to lif...@googlegroups.com, David Pollak
On 2011-01-11 15:27, David Pollak wrote:


On Tue, Jan 11, 2011 at 4:37 AM, Peter Petersson <peterss...@gmail.com> wrote:
Sry David but can you clarify (still a bit confused ;) ), dose the "Basic Lift training video" switch between xhtml and html5 when demonstrating different aspects of lift ?

The materials for the training are available at http://tunaforcats.com/lift_training.tgz

Please look to see if each example is HTML5 or XHTML.
Thank you for clearing it David, yes looking at the code there are both html5 (cool ;) ) and xhtml examples.
Reply all
Reply to author
Forward
0 new messages