Fixes PR12767
This commit is contained in:
parent
41a890df03
commit
6db5672ac5
|
@ -214,22 +214,24 @@ another list that acts as a template. For example, given the list of
|
|||
@|xexpr|s @racket['((li "Larry") (li "Curly") (li "Moe"))], we may want
|
||||
to create the single @|xexpr|
|
||||
|
||||
@racket['(ul (li "Larry")
|
||||
(li "Curly")
|
||||
(li "Moe"))]
|
||||
@racketblock[
|
||||
'(ul (li "Larry")
|
||||
(li "Curly")
|
||||
(li "Moe"))
|
||||
]
|
||||
|
||||
This can't be done using plain unquoting, because placing a comma in front of
|
||||
@racket['("Larry" "Curly" "Moe")] will unquote the entire list, yielding
|
||||
the malformed expression @racket['(ul ((li "Larry") (li "Curly") (li
|
||||
This can't be done using plain unquoting, because placing a comma in
|
||||
front of @racket['((li "Larry") (li "Curly") (li "Moe"))] will unquote
|
||||
the entire list, yielding the malformed expression
|
||||
@racket['(ul ((li "Larry") (li "Curly") (li
|
||||
"Moe")))].
|
||||
|
||||
Instead, we must splice the list in, like so: @racket[`(ul ,@((li "Larry") (li "Curly") (li
|
||||
"Moe")))]. The unquote-splicing form, @racket[,@expression],
|
||||
allows us conveniently to splice a list of @|xexpr| fragments into a
|
||||
larger template list. To generalize
|
||||
the example, here are two helper functions that convert any list of
|
||||
@|xexpr|s into one
|
||||
@|xexpr| representing an unordered, itemized HTML list:
|
||||
larger template list. To generalize the example, here are two helper
|
||||
functions that convert any list of @|xexpr|s into one @|xexpr|
|
||||
representing an unordered, itemized HTML list:
|
||||
|
||||
@racketblock[
|
||||
@code:comment{render-as-itemized-list: (listof xexpr) -> xexpr}
|
||||
|
@ -273,8 +275,8 @@ should produce
|
|||
|
||||
@racketblock[
|
||||
'(div ((class "posts"))
|
||||
(div ((class "post")) "Post 1" "Body 1")
|
||||
(div ((class "post")) "Post 2" "Body 2"))
|
||||
(div ((class "post")) "Post 1" (p "Body 1"))
|
||||
(div ((class "post")) "Post 2" (p "Body 2")))
|
||||
]
|
||||
|
||||
@centerline{------------}
|
||||
|
|
Loading…
Reference in New Issue
Block a user