implicit function producing an attribute

31 views
Skip to first unread message

Byron Weber Becker

unread,
Aug 12, 2015, 3:35:53 PM8/12/15
to Scalatags
I'd like to create an implicit definition to convert from an object I don't have control over to a scalatags attribute.  

The use case is:

(a href := /* do some funky things to myObj to get a URL as a string */)(...)

This works, but what I'd like to write is simply

(a href := myObj)(...)

and have an implicit to the funky stuff for me.

What I want to write generates the following error message:

[error] Test.scala:47: No AttrValue defined for type MyObj; scalatags does not know how to use MyObj as an attribute

[error]           href := myObj)(...)

[error]                ^

[error] one error found


From this I gather that my implicit should have the following signature:

implicit def MyObjToAttrValue(o : MyObj):AttrValue[String] = ???

So...  Once I coax o to give me a URL as string, how do I turn that URL into an AttrValue?

Thanks,
Byron
Reply all
Reply to author
Forward
0 new messages