Scala create xhtml elements dynamically

Posted by portoalet on Stack Overflow See other posts from Stack Overflow or by portoalet
Published on 2010-05-22T19:59:43Z Indexed on 2010/05/22 20:10 UTC
Read the original article Hit count: 191

Filed under:
|
|
|

Given a String array

val www = List("http://bloomberg.com", "http://marketwatch.com");

I want to dynamically generate

<span id="span1">http://bloomberg.com</span>
<span id="span2">http://marketwatch.com</span>

def genSpan(web: String) = <span id="span1"> + web + </span>;

www.map(genSpan); // How can I pass the loop index?

How can I use scala map function to generate the ids (span1, span2), as 1 and 2 are the loop indexes ? Or is the only way is to use for comprehension?

© Stack Overflow or respective owner

Related posts about scala

Related posts about map