What is this code line doing? Is this syntactic sugar for another notation?
def createItem(itemText: String) = <.li(itemText)
<.ul(props map createItem: _*) <-- this one
I assume that you find the line too strange from a purely syntactical point of view.
The <
is a member of another strangely named entity html_<^
.
The <
gizmo is of type HtmlTags, and in particular it has methods li
and ul
, that correspond to tags <li>
and <ul>
.
Therefore <.ul(foobar)
is a method call on <
of the method ul
with arguments foobar
.
The foo: _*
syntax is for passing collections to vararg methods.
To summarize:
props
is some collection that is createItem
and the result is thenul
ofHtmlType
-typed member <
ofhtml_<^
So, essentially, it just constructs an unordered list of some sort.
Here is a brief explanation from the project github page about the naming of these methods:
Tags and tag attributes are namespaced; tags under < (because <.div looks similar to ), and attributes under ^ (because something concise was needed and you usually have many attributes which written on new lines all looks to point up back to the target tag).