meta-like snippets with expansion of macros? #58

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

Hi,
Sorry if this is an obvious question, I'm new to pollen and racket.

I want to be able to define a title and abstract snippet in a page and then use that in the page template and other pages such as an overview page. The issue is that those snippets should expand all included macros, like for math, links and formatting. Something like

◊abstract{Properties of Hilbertspace ◊m{\mathcal{H}} }

where I have ◊m defined in pollen.rkt.

I've tried the pattern above and can get the expanded expression and insert it into a template with ◊(->html (select* 'abstract doc)). That works great, but I don't know how to remove the abstract tag from the doc so ◊(->html doc) doesn't also include it on the page at the point where I defined it. How would I filter doc so certain tags and content was dropped?

The other approach I've tried is to use metas with

◊define-meta[abstract]{◊@{Properties of Hilbertspace ◊m{\mathcal{H}} }}

and inserting it with ◊(->html (decode-elements (select* 'abstract metas))) but that seems to expand only html tags such as ◊em{this}, not the ones I've defined in the pollen.rkt file.

Are either of these the right approach?

Hi, Sorry if this is an obvious question, I'm new to pollen and racket. I want to be able to define a title and abstract snippet in a page and then use that in the page template and other pages such as an overview page. The issue is that those snippets should expand all included macros, like for math, links and formatting. Something like ``` ◊abstract{Properties of Hilbertspace ◊m{\mathcal{H}} } ``` where I have ◊m defined in pollen.rkt. I've tried the pattern above and can get the expanded expression and insert it into a template with `◊(->html (select* 'abstract doc))`. That works great, but I don't know how to remove the abstract tag from the doc so `◊(->html doc)` doesn't also include it on the page at the point where I defined it. How would I filter `doc` so certain tags and content was dropped? The other approach I've tried is to use metas with ``` ◊define-meta[abstract]{◊@{Properties of Hilbertspace ◊m{\mathcal{H}} }} ``` and inserting it with `◊(->html (decode-elements (select* 'abstract metas)))` but that seems to expand only html tags such as `◊em{this}`, not the ones I've defined in the pollen.rkt file. Are either of these the right approach?
mbutterick commented 4 years ago (Migrated from github.com)

In your template, rather than using select, you can separate the abstract tags from the rest with splitf-txexpr. Then you can handle them separately in the HTML.

In your template, rather than using `select`, you can separate the `abstract` tags from the rest with [`splitf-txexpr`](https://docs.racket-lang.org/txexpr/index.html?q=splitf-txexpr#%28def._%28%28lib._txexpr%2Fmain..rkt%29._splitf-txexpr%29%29). Then you can handle them separately in the HTML.
aalexei commented 4 years ago (Migrated from github.com)

Awesome. That worked a treat, thanks!

Awesome. That worked a treat, thanks!
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#58
Loading…
There is no content yet.