One source file → multiple outputs of same type?
#122
Closed
opened 3 years ago by jaybonthius
·
6 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 know I can have multiple poly-targets, like
html
,txt
,ltx pdf
, but can I have multiple poly-targets of the same type?My use case: I'm writing lecture notes and I would like to add a second
html
poly-target for some sort of javascript browser slideshow.I'm hoping for the following: a single source file
lecture.poly.pm
is rendered as two separatehtml
files:lecture-doc.html
,lecture-slides.html
, each processed through their own separate branches of tag functions.Is that doable?
In the same vein, I see a similar use case with
pdf
:exam.poly.pm
renders intoexam.pdf
andexam-solutions.pdf
, where in the latter, solutions are made visible.As a work-around I once did this with
htm
andhtml
as different targets. But in general, I think you can make the targetsdoc.html
,slides.html
,default.pdf
andsolutions.pdf
. (resulting inexam.default.pdf
etc.)The reverse use case (many source files → one output file) came up recently, and the answer is much the same (see the second point in this comment). Thanks to the fact that Pollen sources are also Racket modules, whatever you need can be done by just writing your own code rather than depending solely on Pollen’s built-in command line tools.
The simplest hack I would try, given your “each processed through their own separate branches of tag functions” requirement, is to have
html_l
andhtml_s
output targets, and then rename all the resulting files to.html
with a shell script. But eventually you may find that you want to create your own Racket program that just builds everything you need in one go.Those sound like great solutions until I work up the courage to implement a Racket-based mechanism. Thank you, Joel and @bdeket!
I handle situations like this by using the
POLLEN
environment variable.This is how typographyforlawyers.com and practicaltypography.com are generated from a single set of source files. Most of the text is shared. But then I have tag functions that show or hide certain text based on the status of an environment variable.* Then everything else is the same (templates, etc.)
* Strictly speaking,
POLLEN
is automatically supported, but you can use any environment variable and then add it toenvvar-watchlist
so it cooperates with the caching system.Ah, that's a cool solution. I was wondering how you managed both sites from one set of sources. Thanks for the tip!