pollen-users icon indicating copy to clipboard operation
pollen-users copied to clipboard

Adding tags in the sense of categories?

Open Macavirus opened this issue 4 years ago • 2 comments

One common use that I couldn’t find easily described in the tutorials is creating tags for content such as are present in e.g. WordPress. (Meaning, not XML tags or tag functions, but tags like metadata applying to multiple items in a hierarchy).

E.g., you might tag a document “legal”, “update”, “technology”, etc.

I realize this is probably very basic Racket that I’m misunderstanding.

The best way I could guess to do this would be to add ◊(define-meta) at the top of a document and give it a list.

◊(define-meta my-tags '("legal" "update" "technology"))

Then in a template.html.pm, use something like

<ul>
  ◊(map ◊li{◊select*['my-tags metas]})
</ul>

This doesn’t work because something about the syntax is incorrect, but is it on the right track?

Macavirus avatar Apr 06 '20 07:04 Macavirus

You should use

◊(define-meta my-tags ("legal" "update" "technology"))

because the RHS of define-meta is auto-quoted.

For template.html.p, you probably should have something like:

◊(->html (apply ul (map li (select-from-metas 'my-tags metas))))

sorawee avatar Apr 06 '20 08:04 sorawee

@sorawee It works! Thank you.

I also found out you can do it with for/splice something like:

        ◊for/splice[[(item (in-list (select* 'my-tags metas)))]]{
            <div>◊|item|</div>
        }

I found it odd that the auto-quoting of define-metas was not documented. Thanks for the tip.

Macavirus avatar Apr 06 '20 19:04 Macavirus