I wanted to define simple link element but I couldn't make it work and with 
my scarred ego I searched for existing implementation - finding one in the 
pollen-tfl. To my surprise/relief I found exactly the same problem there. 
Here is the code to try:
#lang pollen
◊(require txexpr)

◊(define (link url #:class [class-name #f] . tx-elements)
         (let* ([tx-elements (if (empty? tx-elements)
                                 (list url)
                                 tx-elements)]
                [link-tx (txexpr 'a empty tx-elements)]        
                [link-tx (attr-set link-tx 'href url)])
           (if class-name
               (attr-set link-tx 'class class-name)
               link-tx)))

◊link["www.google.com"]{This is a text for the link}

The expected result would be:
'(a ((href "www.google.com")) "This is a text for the link")

instead tx-elements is treated as empty which results in:
'(a ((href "www.google.com")) "www.google.com")

Trying the same code with just at-exp racket:
#lang at-exp racket
@(require txexpr)

@(define (link url #:class [class-name #f] . tx-elements)
         (let* ([tx-elements (if (empty? tx-elements)
                                 (list url)
                                 tx-elements)]
                [link-tx (txexpr 'a empty tx-elements)]        
                [link-tx (attr-set link-tx 'href url)])
           (if class-name
               (attr-set link-tx 'class class-name)
               link-tx)))

@link["www.google.com"]{This is a text for the link}

Results in the correct output:
'(a ((href "www.google.com")) "This is a text for the link")

Am I missing something simple? Can you replicate it on your machines?

Thanks

Greg

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to