The title tag is not working as expected with the ScalaTags library.
import scalatags.Text.all._
title("My Awesome Website")
How can I get this to work?
Help docs/tutorials are conveniently missing the ubiquitous title tag. I hope the dev fixes this..
https://github.com/lihaoyi/scalatags
Not Working as Expected:
If you look at how tags such as link
, script
, head
, html
are used the title
tag should work the same.
For some reason the dev chose to make this tag ConcreteHtmlTag[Nothing]
rather than the former tag's type ConcreteHtmlTag[String]
. Its also strange that this tag is in the Tags2
package rather than Tags
, it is a commonly used tag after all.
This one seems to work:
scala> scalatags.Text.tags2.title("test")
res7: scalatags.Text.TypedTag[Nothing] = <title>test</title>
It seems like the title
in scalatags.Text.all
is a tag attribute (scalatags.generic.Attr
) and not a TypedTag
. Whether or not this is misplaced or not (or should be TypedTag[String]
), I don't know. Perhaps it's just a symbol collision in your code.
An explicit import scalatags.Text.tags2.title
ought to help.
Instead of importing all
, there are alternate imports you can use.
import scalatags.Text.short._
import scalatags.Text.tags2._
html(
head(
title("Your Title Here")
),
body(
)
)
More examples are in Managing Imports section in docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With