Adding tags in the sense of categories? #39

Open
opened 4 years ago by Macavirus · 2 comments
Macavirus commented 4 years ago (Migrated from github.com)

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?

One common use that I couldn&rsquo;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 &ldquo;legal&rdquo;, &ldquo;update&rdquo;, &ldquo;technology&rdquo;, etc. I realize this is probably very basic Racket that I&rsquo;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&rsquo;t work because something about the syntax is incorrect, but is it on the right track?
sorawee commented 4 years ago (Migrated from github.com)

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))))
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 commented 4 years ago (Migrated from github.com)

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

@sorawee It works! Thank you. I also found out you can do it with `for/splice` something like: ``` racket ◊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.
This repo is archived. You cannot comment on issues.
No Milestone
No project
No Assignees
1 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mbutterick/pollen-users#39
Loading…
There is no content yet.