Skip to content
This repository has been archived by the owner on Sep 17, 2022. It is now read-only.

Adding tags in the sense of categories? #39

Open
Macavirus opened this issue Apr 6, 2020 · 2 comments
Open

Adding tags in the sense of categories? #39

Macavirus opened this issue Apr 6, 2020 · 2 comments

Comments

@Macavirus
Copy link

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?

@sorawee
Copy link

sorawee commented Apr 6, 2020

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))))

@Macavirus
Copy link
Author

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants