rename `make-txexpr` to `txexpr`

dev-fixit
Matthew Butterick 9 years ago
parent 2d16074938
commit 4264ee9856

@ -143,12 +143,12 @@
[else (error 'validate-txexpr (format "~v is not a list starting with a symbol" x))]))
(define+provide+safe (make-txexpr tag [attrs null] [elements null])
(define+provide+safe (txexpr tag [attrs null] [elements null])
((symbol?) (txexpr-attrs? txexpr-elements?) . ->* . txexpr?)
(define result (cons tag (append (if (empty? attrs) empty (list attrs)) elements)))
(if (txexpr? result)
result
(error 'make-txexpr
(error 'txexpr
(cond
[(not (txexpr-tag? tag))
(format "This is not a txexpr-tag: ~v" tag)]
@ -158,6 +158,8 @@
(format "This is not a list of txexpr-elements: ~v" elements)]
[else ""]))))
(define make-txexpr txexpr)
(provide+safe make-txexpr)
(define+provide+safe (txexpr->values x)
(txexpr? . -> . (values symbol? txexpr-attrs? txexpr-elements?))

@ -271,7 +271,7 @@ Accessor functions for the individual pieces of a @racket[_txexpr].
]
@defproc[
(make-txexpr
(txexpr
[tag txexpr-tag?]
[attrs txexpr-attrs? @empty]
[elements txexpr-elements? @empty])
@ -279,15 +279,24 @@ txexpr?]
Assemble a @racket[_txexpr] from its parts. If you don't have attributes, but you do have elements, you'll need to pass @racket[empty] as the second argument. Note that unlike @racket[xml->xexpr], if the attribute list is empty, it's not included in the resulting expression.
@examples[#:eval my-eval
(make-txexpr 'div)
(make-txexpr 'div '() '("Hello" (p "World")))
(make-txexpr 'div '[[id "top"]])
(make-txexpr 'div '[[id "top"]] '("Hello" (p "World")))
(txexpr 'div)
(txexpr 'div '() '("Hello" (p "World")))
(txexpr 'div '[[id "top"]])
(txexpr 'div '[[id "top"]] '("Hello" (p "World")))
(define tx '(div [[id "top"]] "Hello" (p "World")))
(make-txexpr (get-tag tx)
(txexpr (get-tag tx)
(get-attrs tx) (get-elements tx))
]
@defproc[
(make-txexpr
[tag txexpr-tag?]
[attrs txexpr-attrs? @empty]
[elements txexpr-elements? @empty])
txexpr?]
Alternate name for @racket[txexpr].
@defproc[
(can-be-txexpr-attrs?
[v any/c])

@ -77,6 +77,12 @@
(check-txexprs-equal? (make-txexpr 'p null '("foo" "bar")) '(p "foo" "bar"))
(check-txexprs-equal? (make-txexpr 'p '((key "value")) (list "foo" "bar"))
'(p ((key "value")) "foo" "bar"))
(check-txexprs-equal? (txexpr 'p) '(p))
(check-txexprs-equal? (txexpr 'p '((key "value"))) '(p ((key "value"))))
(check-txexprs-equal? (txexpr 'p null '("foo" "bar")) '(p "foo" "bar"))
(check-txexprs-equal? (txexpr 'p '((key "value")) (list "foo" "bar"))
'(p ((key "value")) "foo" "bar"))
(check-equal? (values->list (txexpr->values '(p)))
(values->list (values 'p null null)))

Loading…
Cancel
Save