@ -177,15 +177,14 @@ Be careful if you're working with integers and X-expressions — a raw integer i
@subsection{Parsing attributes}
@subsection{Parsing attributes}
Detecting attributes in an argument list can be tricky because a) the tag may or may not have attributes, b) those attributes may be in standard or abbreviated syntax. For this reason, Pollen provides a @racket[split-attributes] function (in the @racket[pollen/tag] library) that you can use in custom tag functions to separate the attributes and elements:
Detecting attributes in an argument list can be tricky because a) the tag may or may not have attributes, b) those attributes may be in standard or abbreviated syntax. For this reason, Pollen provides a @racket[define-tag-function] macro (in the @racket[pollen/tag] library) that you can use in custom tag functions to separate the attributes and elements:
@ -58,18 +58,16 @@ Note that while default tag functions are typically used to generate tagged X-ex
@defproc[
@defform[
(split-attributes
(define-tag-function
[parts list?])
(tag-id attr-id elem-id) body ...)]
(values txexpr-attrs? txexpr-elements?)]
Helper function for making custom tag functions. Handles parsing chores, including conversion of keyword arguments into attributes (described in @racket[make-default-tag-function]), and parses other attributes and elements normally.
Helper function for custom tag functions. Take a rest argument that possibly includes tag attributes plus elements, and split it into attributes and elements. If there are no attributes, that return value will be the empty list. Properly parses the abbreviated Pollen syntax for attributes (described in @racket[make-default-tag-function]).
(raise-syntax-error'define-tag-function(format"bad syntax (no expressions for procedure body) in ~a"(syntax->datumstx)))]
[(_ID(λ(ARG...)EXPR...))(raise-syntax-error'define-tag-function(format"bad syntax (arity must be exactly 2 positional arguments) in ~a"(cadr(syntax->datumstx))))]))