My problem is extracting xhtml attributes to generate absolute links,
since they need to be different on testing and production
environment.
I would like to use a “global snippet” that binds all “src” and “href”
attributes to “localhost:8080” or “www.mydomain.com” depending on a
conf value.
This is how the template looks like:
<lift:Global>
<html><body><a G:href="/somelink">some text</a></body></html>
</lift:Global>
And this is the Global.render method:
bind("G",template,
AttrBindParam("href",Conf.localhost
+BindHelpers.attr("G","href").map(_.toString).getOrElse("none") ,"href")
)
But in the rendered page all I see is … href=”confValueNone”.
What am I doing wrong?
Is there a better way to configure for different environments?
I use AttributeSnippets now. They are a bit heavier on the template side, but result in cleaner snippets.
snippet:
template: