Meta values not evaluated?
#104
Closed
opened 4 years ago by casouri
·
4 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
I have a small helper
jpgs
that marks a piece of text Japanese:In
pollen.rkt
:And in my document I set the
artist
meta to "流線形":In
day-22.html.pm
:Finally, I insert the artist information in my template:
In
template.html.p
:However in the output file (
day-22.html
), I get<jpns>流線形</jpns>
instead of<span class="jpns">流線形</span>
.Is this just how metas work? Is there any way to work around this? Thanks in advance.
metas
is a hash table (specifically ahasheq
), so it can only hold literal values. In this case, you are inserting◊jpns{流線形}
hoping it will be evaluated as code later. But no — it is treated as the literal X-expression'(jpns "流線形")
.You could just use
"流線形"
as the meta value, and put thejpns
tag in the template.You could just use
jpns
as a tag. Web browsers treat unspecified tags asspan
elements.Thanks! I cannot use either of the two approaches. I can't put the
jpns
tag in the template because there are artist names that are not in Japanese, and I can't detect the language automatically because CJK characters could be Chinese, Korean, Japanese, etc. For the second approach, I have more complicated contents like links that I want to put into meta, those cannot work literally.However, knowing that metas won't cut it, I came up with this. I split the document into two sections,
head
andbody
:And in the template, I extract values from
head
and only show the content inbody
:Hopefully, this could help others that need to generate structural content.
Note that you can alter
(current-metas)
from within a tag function, which would allow you to place the result of an expression in your metas. This is partially becausecurrent-metas
is a parameter than can be updated, and partially because Pollen is designed to preserve any updates that remain afterroot
is finished.Example
pollen.rkt
:Example source file:
Result of “running” the above file in the DrRacket REPL:
Thanks! This is really helpful.