raco pollen start
uses incorrect template in nested directory
#47
Closed
opened 10 years ago by basus
·
3 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 pollen project set up which has a couple of directories under the main one. Each of the nested directories has it's own
template.html
so that I can generate different types of pages. I've been runningraco pollen start
in the top-level directory for development work. However, it seems like for generating pages in the nested directories, it's still using the top-leveltemplate.html
file, rather the one corresponding to each directory. If I runraco pollen render
inside each directory, it uses the correct one.The behavior you describe is intentional. My idea with
template.html
was just to provide unsurprising default behavior for the simple case of a single-directory project. See the docs for get-template-for, which explain how a template is chosen.The
template.html
in the project directory is used only when there’s no template explicitly specified using ameta
tag. And the project directory is always the one where you doraco pollen start
.If you want source files in subdirectories to use a different template, you have two choices.
metaroot
tag function in thedirectory-require.rkt
file that can process the metas. By usingmetaroot
, you can append a'template
meta to every source file in that directory.metaroot
is an X-expression that just holds a list ofmeta
tags, like so:So for instance, this
metaroot
tag function will set the template for all the files in this directory to"new-template.html"
:Keeping with the usual logic of metas, later metas with the same name overwrite earlier ones. The function above guarantees that the files use
"new-template.html"
(because it comes last). If you want to still allow per-file overrides, you could switch it around like so:Thanks much. The metaroot approach seems handy for my current use case.
Warning: I just pushed an update that changes the format of the list of
metas
that are passed tometaroot
. It used to be a list of metas where the key-value pairs are attributes:Now, it’s a list where the key-value pairs are tagged X-expressions:
Moreover, rather than just holding strings,
metas
can now hold one or more X-expressions, so things like this are possible:More info on the change.