Arc Forumnew | comments | leaders | submitlogin
2 points by fallintothis 5648 days ago | link | parent

The 'li function could be simplified. html.arc has the facilities to define tags; coupled with 'tostring, we can capture the output, giving something like:

  (attribute li class opstring)
  (attribute li id    opstring)
  
  (def li items
    (tostring
      (each i items
        (if (isa i 'table)
            (tag (li class i!class id i!id) (pr i!body))
            (tag li (pr i))))))
This also uses a rest parameter so that 'li can take any number of arguments and collect them up into a list:

  arc> (li (obj body "hi" id "brown") (obj body "world" class "green") "foo")
  "<li id=\"brown\">hi</li><li class=\"green\">world</li><li>foo</li>"
Though it doesn't quite replicate the use of 'string you had originally, e.g.,

  arc> (li ''(a b c))        ; the one defined above
  "<li>(quote (a b c))</li>"
  arc> (li (list ''(a b c))) ; yours
  "<li>quoteabc</li>"
You note that 'gentag prints all over the place. I'm sure (because of the game you built) you notice that Arc uses printing in its html-generation tools. So if you wanted to use this 'li function inside, say, a 'defop, you probably don't want to wrap it in the 'tostring -- instead, let it print so that you don't have to make the call to 'pr yourself.


1 point by coconutrandom 5643 days ago | link

Thanks for the info, didn't know the 'tostring did that!

The reason I didn't want it to pr at the moment was the output from this or other functions could be assembled to make a html template system.

-----