Difficulties defining custom attributes with v0.3.5

35 views
Skip to first unread message

Richard Gomes

unread,
Jun 24, 2014, 11:15:08 PM6/24/14
to scal...@googlegroups.com
Hi,

I've recently migrated to Scalatags 0.3.5 and my code is not compiling anymore.
In a nutshell, custom attributes were a SortedMap before and now they are List[Seq[Modifier]].

Could you please tell me what I'm missing in the code below?  Thanks a lot in advance :)


import scalatags.Text._
import scalatags.Text.all._
import scalatags.Escaping
import scalatags.Platform
import scalatags.generic
import scalatags.text

object dojo {

  val `data-dojo-id`    : Attr = "data-dojo-id".attr
  val `data-dojo-type`  : Attr = "data-dojo-type".attr
  val `data-dojo-props` : Attr = "data-dojo-props".attr

  object dijit {
    val select   = "select".dtag[form.SelectElement]("dijit/form/Select")
    val combobox = "input".dtag[form.ComboBoxElement]("dijit/form/ComboBox")

    object form {
      class SelectElement extends dom.HTMLSelectElement
      class ComboBoxElement extends dom.HTMLSelectElement
    }
  }

  object store {
    val memory   = "div".dtag[MemoryElement]("dojo/store/Memory")

    class MemoryElement extends dom.HTMLDivElement
  }

  implicit class DojoConversions(s: String) {
    def dtag[T <: Platform.Base](dtype: String) = {
      if (!Escaping.validTag(s))
        throw new IllegalArgumentException(s"Illegal tag name: $s is not a valid XML tag name")

      //----------- how do I build a List[Seq[Modifier]] ? --------------------------
      val y = `data-dojo-type` := dtype
      TypedTag(s, `data-dojo-type` := dtype, false)
      //-----------------------------------------------------------------------------

    }
  }
}


Message has been deleted

Richard Gomes

unread,
Jun 24, 2014, 11:24:38 PM6/24/14
to scal...@googlegroups.com
NOTE: If my code is rubbish, please just let me know. I'm happy to adopt your suggestions.

Haoyi Li

unread,
Jun 25, 2014, 10:58:47 AM6/25/14
to Richard Gomes, scal...@googlegroups.com
I don't immediately know what you're trying to do, but what's wrong with 

TypedTag(s, List(List(`data-dojo-type` := dtype)), false)

?




On Tue, Jun 24, 2014 at 8:24 PM, Richard Gomes <rgome...@gmail.com> wrote:
NOTE: If my code is rubbish, please just let me know. I'm happy to adopt your suggestions.

--
You received this message because you are subscribed to the Google Groups "Scalatags" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalatags+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Richard Gomes

unread,
Jun 25, 2014, 9:48:36 PM6/25/14
to scal...@googlegroups.com, rgome...@gmail.com
Yeah, it works!

I guess it was a problem between the monitor and the chair. And it wasn't the keyboard. :D

Thanks a lot :)

-- Richard
Reply all
Reply to author
Forward
0 new messages