OPA mapi syntax error
So I have a database record that contains a field with a list(string) I would like to convert this list of strings to some xhtml to display.
I've written the following function:
display_lp(path) = (
do List.mapi(x, characterlp -> <div class="show_content" id=#show_content > {x} : <textarea class="edit_content" id=#edit_content_lp cols="20" rows="1"> {characterlp} </textarea></div> ), /characters[path]/lifepaths -> y
XMLConvert.of_list_using("","","",y)
)
however it doesn't compile. It gives me a syntax error:
Syntax error at line 270, column 188 The error may be in the following citation, usually in the red part (starting at ⚐) or 开发者_如何学运维just before: <<) void )
display_lp(path) = ( do List.mapi(x, characterlp -> {x} : {characterlp} )⚐, /characters[path]/lifepaths -> y XMLConvert.of_list_using("","","",y) )
display(path) = (
> Hint: expected (while parsing starting at line 270, column 188) Error Syntax error
What am I doing wrong here?
This is what i guess what you wanted to do :
display_lp(path) =
y = List.mapi(
x, characterlp ->
<div class="show_content" id=#show_content>
{x}:
<textarea class="edit_content" id=#edit_content_lp cols="20" rows="1">
{characterlp}
</textarea>
</div>
, /characters[path]/lifepaths)
XmlConvert.of_list_using(<></>,<></>,<></>,y)
First, your List.mapi is mis-parenthesed
Secondly, I don't understand your
-> y
after/characters[path]/lifepaths
, i guess you wanted to put the result of List.mapi in they
variable.Third, there is a typo : this is
XmlConvert
and NOTXMLConvert
(uppercase)Finally, XmlConvert has for signature :
xhtml, xhtml, xhtml, list(xhtml)
That means you must provide type xhtml for the first 3 arguments, which is not compatible with the type string "" :)
The equivalent of "" in xhtml is <>
Hope that solves your problem.
精彩评论