Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Li Haoyi
    @lihaoyi
    @/all my book Hands-on Scala Programming is out https://www.handsonscala.com/, with multiple chapters using Scalatags heavily. If you like using Scalatags, you should definitely check it out :)
    Soren
    @srnb_gitlab
    Is it possible to have a project where it outputs a single HTML file with ScalaJS code embedded? I.e. in a <script>blah</script> and not a <script src="blah"></script>
    So far I'm thinking I should just make a JVM project that reads the output from ScalaJS and then an SBT task that runs mySJS/fullOptJS::webpack before the JVM project runs, but I want to know if there's an easier solution
    Marcin Józefowicz
    @marcin-jozefowicz

    Hi!
    Do you know how I can test Text.TypedTag[String] against structure and content? I have spot only method modifiers but I don't know what to do next to get the structure? Any hint will be aprreciated.

    result.modifiers.flatten.map(a => {
          println(a.leftSide)
          println(a.leftSideValue)
        }

    Or maybe there is only to examine output base on generated string ?

    Li Haoyi
    @lihaoyi
    Scalatags doesn’t really expose any stable data structure for you to test against, your best bet might be parsing the output string using JSoup and then querying it to do your tests
    Marcin Józefowicz
    @marcin-jozefowicz
    Thanks @lihaoyi
    Sakib Hadžiavdić
    @sake92
    there is support for Selenium embedded in ScalaTest also :)
    nafg
    @nafg
    How hard would it be to implement a scalatags module that built a plain data structure?
    Li Haoyi
    @lihaoyi
    not terribly hard, we already have modules that build vdom nodes and dom nodes
    Bruno Medeiros
    @bruno-medeiros
    Heya folks, why is this import failing:
    import scalatags.JsDom.all._ (says it cannot find JsDom)
    I have libraryDependencies += "com.lihaoyi" %% "scalatags" % "0.9.1" in build.sbt
    Bruno Medeiros
    @bruno-medeiros
    okay... newbiew mistake, should have been "com.lihaoyi" %%% "scalatags" % "0.9.1"
    Andreas Jim-Hartmann
    @devkat
    Hi all, I’m trying to use an optional attribute:
        val fontFamilyAttr = style.get(FontFamily).map(fontFamily := _)
        tspan(
          fontFamilyAttr,
          chars.mkString
        )
    But I get this error:
    type mismatch;
    [error]  found   : Option[scalatags.generic.AttrPair[org.scalajs.dom.Element,String]]
    [error]     (which expands to)  Option[scalatags.generic.AttrPair[org.scalajs.dom.raw.Element,String]]
    [error]  required: scalatags.JsDom.Modifier
    [error]     (which expands to)  scalatags.generic.Modifier[org.scalajs.dom.raw.Element]
    [error]       fontFamilyAttr,
    The relevant imports look like this:
    import scalatags.JsDom.all.{fontFamily => _, _}
    import scalatags.JsDom.svgAttrs.{OptionFrag => _, SeqFrag => _, _}
    import scalatags.JsDom.svgTags.{OptionFrag => _, SeqFrag => _, _}
    (see lihaoyi/scalatags#209 regarding the disabled imports)
    Any hints are very welcome
    I tried this:
        val fontFamilyAttr = OptionFrag(style.get(FontFamily).map(fontFamily := _))
    No implicit view available from scalatags.generic.AttrPair[org.scalajs.dom.Element,String] => scalatags.generic.Frag[org.scalajs.dom.Element,org.scalajs.dom.Node].
    [error]     val fontFamilyAttr = OptionFrag(style.get(FontFamily).map(fontFamily := _))
    Andreas Jim-Hartmann
    @devkat
    It works with these imports:
    import scalatags.JsDom.all._
    import scalatags.JsDom.svgAttrs.{x, y}
    import scalatags.JsDom.svgTags.{g, text, tspan}
    Soren
    @srnb_gitlab
    How can I use ScalaTags CSS to override default settings?
    I.e. apply a style to <body> instead of a new class
    Win Wang
    @wiwa

    I.e. apply a style to <body> instead of a new class

    Bump. I think the "normal" way is to use a link with href to the static css. But obviously we can't do that :grimacing:

    Win Wang
    @wiwa
    Specifically, trying to use scalatags with http4s, not sure how to deal with CSS in this case :)
    Sakib Hadžiavdić
    @sake92
    what about scalacss maybe?
    Win Wang
    @wiwa
    i could use that but considering how scalatags supports css already, i feel sadness
    Li Haoyi
    @lihaoyi
    scalatags css is just one of many possible approaches, if it doesnt work for your use case don’t use it
    Kevin Meredith
    @kevinmeredith
    :question: Hi - could someone please point me to a basic example of using this library for building a simple <form> that submits application/x-www-form-urlencoded? Thanks!
    Li Haoyi
    @lihaoyi
    isn't the application-x-www-form-urlencoded thing handled by the browser? so it would just be a vanilla HTML <form>
    Kevin Meredith
    @kevinmeredith

    isn't the application-x-www-form-urlencoded thing handled by the browser?

    Yes, that's my understanding per https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form.

    so it would just be a vanilla HTML <form>

    Could you please point me to such an example?

    Kevin Meredith
    @kevinmeredith
    Thank you, @lihaoyi , for your help and this library!
    ^^ Oh - I was asking about a simple <form> example in ScalaTags. After reviewing the well-written README, https://www.lihaoyi.com/scalatags/, I don't recall seeing a form example.
    Li Haoyi
    @lihaoyi
    oh it's just a mechanical translation between scalatags and HTML, so I didn't put one in
    in fact, it's so mechanical that often http://simerplaha.github.io/html-to-scalatags-converter/ is enough :P
    i use it quite often when copying HTML from documentation pages of libraries like bootstrap
    Li Haoyi
    @lihaoyi
    works like 97% of the time
    Kevin Meredith
    @kevinmeredith
    Thanks!
    Sakib Hadžiavdić
    @sake92
    Anyone knows how can I get this to work? https://scalafiddle.io/sf/f8vAr2s/1
    I'm just trying to abstract over AttrPairs in ScalaJS, but it seems impossible... :smile:
    tried to help it compile in lihaoyi/scalatags#205 but it doesnt work in runtime
    Sakib Hadžiavdić
    @sake92
    Li Haoyi
    @lihaoyi
    @sake92 I don't have any immediate ideas why that doesn't work, you might have to poke around JsDom.scala and see if you can figure out what it's doing wrong.
    Sakib Hadžiavdić
    @sake92
    @lihaoyi My bad.. :sweat_smile:
    I used Option[AttrPair]s and compiler got really mad at me..
    diverging implicit expansion for type Nothing => ba.sake.hepek.scalatags.Frag
    [error] starting with method bindNode in trait LowPriorityImplicits
    [error]       inputLabel.map(l => label(inputId.map(`for` := _.v)))
    Sakib Hadžiavdić
    @sake92
    if we could just get a new version carved out that would be great
    even better would be to get this fixed also.. :smile:
    lihaoyi/scalatags#200
    Sakib Hadžiavdić
    @sake92
    @lihaoyi could you please review this one? lihaoyi/scalatags#213
    And release a new version?
    Suvorovkot
    @Suvorovkot

    Hi!
    I am adding to dependencies "com.lihaoyi" %% "scalatags" % "0.8.6"
    Then it is added external libraries and IntelliJ idea marks import scalatags.Text.all._ as a correct import
    Though during sbt compile i've got this error not found: object scalatags

    Could anyone please tell me what may be the problem?

    Sakib Hadžiavdić
    @sake92
    did you reload sbt session after adding dependency?
    Suvorovkot
    @Suvorovkot
    Yep
    Suvorovkot
    @Suvorovkot
    It helped to import "com.lihaoyi" % "scalatags_2.12" % "0.9.2"
    nafg
    @nafg
    @Suvorovkot you should let %% add the _2.12 for you