To be parsed by the bind, it must be enclosed by 
<lift:HelloWorld.hello>...</lift:HelloWorld.hello>

There is relatively little magic -- Lift goes through your template looking for 
lift: prefixed tags. For those tags, it will look up a snippet class by using 
the part before the period (HelloWorld, in the above example) and then look for 
a method on that snippet class mentioned after the period (hello in the 
example). If there is no period, the method is assumed to be called "render".

Once that method is found, the method is called with the contents of the lift: 
tag, and the result of the method call is spliced into the XML to replace the 
lift: tag.

bind is a function that does something kind of similar to overall template 
processing, except you supply some prefix other than lift: (b: in the example) 
and a limited set of things after the colon that are valid (time and meta_desc 
in the example)

So, you might want something like this instead:

<meta name="description"><lift:HelloWorld.meta_desc /></meta>

class HelloWorld {
    ....
    def meta_desc(ns: NodeSeq): NodeSeq = Text("test desc")
    ....
}

Which will result in this XHTML:

<meta name="description">test desc</meta>

Or, if you want to keep it in the hello method, you'd then have to move the 
<lift:HelloWorld.hello> to the outside of the template:

<lift:HelloWorld.hello>
   ...
   <head>
        <meta name="description"><b:meta:desc /></meta>
    </head>
    ...
    <b:time />
</lift:HelloWorld.hello>

Hope that helps,
-Ross


On Mar 7, 2010, at 4:38 AM, Martin wrote:

> How would one go about having dynamic description and keyword meta
> tags in a template? Here is what i've tried:
> 
> default.html
> <meta name="description"><b:meta_desc /></meta>
> 
> HelloWorld.scala
> Helpers.bind("b", in, "time" -> date.map(d => Text(d.toString)),
> "meta_desc" -> "test desc")
> 
> I'm using a basic archetype build of 2.0-M3 and it produces an error:
> 
> This page contains the following errors:
> 
> error on line 6 at column 28: Namespace prefix b on meta_desc is not
> defined
> Below is a rendering of the page up to the first error.
> 
> 
> It appears to me that the template is not parsed by the Helpers.bind,
> is this correct?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Lift" group.
> To post to this group, send email to lift...@googlegroups.com.
> To unsubscribe from this group, send email to 
> liftweb+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/liftweb?hl=en.
> 

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

Reply via email to