6.1.0.5
11.7 Tag
Convenience functions for working with tags.
Make a default tag function for
id. As arguments, a tag function takes an optional set of X-expression attributes (
txexpr-attrs?) followed by X-expression elements (
txexpr-elements?). From these, the tag function creates a tagged X-expression using
id as the tag.
Entering attributes this way can be cumbersome. So for convenience, a tag function provides an alternative: any symbol + string pairs at the front of your expression will be interpreted as attributes, if the symbols are followed by a colon. If you leave out the colon, the symbols will be interpreted as part of the content of the tag.
Examples: |
> (require pollen/tag) | | > (define beaucoup (make-default-tag-function 'em)) | | > (beaucoup 'id: "greeting" 'class: "large" "Bonjour") | '(em ((id "greeting") (class "large")) "Bonjour") | ; Don't forget the colons | > (beaucoup 'id "greeting" 'class "large" "Bonjour") | '(em id "greeting" class "large" "Bonjour") | ; Don't forget to provide a value for each attribute | > (beaucoup 'id: 'class: "large" "Bonjour") | '(em id: class: "large" "Bonjour") |
|
Pollen also uses this function to provide the default behavior for undefined tags. See #%top.
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
make-default-tag-function).
Examples: |
> (require pollen/tag) | | | | > (tag "Hello world") | | > (tag '((key "value")) "Hello world") | '((key "value")) | '("Hello world") |
| > (tag 'key: "value" "Hello world") | '((key "value")) | '("Hello world") |
|
|