look into rendering problem with suffix-free source files
#130
Closed
opened 8 years ago by mbutterick
·
7 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?
@agmck If this update doesn't fix your problem with suffix-free source files, let me know.
That's terrific, Matthew. Thanks a lot! Pagetrees and the project server also seem to work.
I do want to reiterate the point I made in the group; namely that poly output isn't really useful without a suffix, all files will render to the suffix-free filename.
Perhaps we need to rethink output paths more generally. I think it's too much for a lowly markup file to know about its own output targets, but what about specifying poly-target + output path pairs in the pagetree?
For a source file example.pm —
'(example.pm ((html "example/index.html") (txt "example.txt") (pdf "chapter-one.pdf")))
This would allow us to loosen the unreasonably tight coupling between the structure of the source files and their deployment target. If there's anything I can do, let me know.
IIUC, the main issue is that you want to be able to specify arbitrary output names, per source file & per render target.
If so, I think that information should either live a) in the source file itself (similar to
(define-meta template ...)
) or b) thesetup
module should support a function that calculates output paths, and that could branch based oncurrent-poly-target
. Or both, since they can work together: the rule would be “use the output-path generator function unless there’s an explicit output path specified in the source file.”Can you clarify why you want to be able to write a
poly
file without a suffix? Thepoly
suffix is a signal that Pollen needs to handle that source file specially. Of course, thepoly
suffix itself eventually disappears when it gets swapped for the output suffix.Correct. Adding that information as metadata was my first thought as well. But then I asked myself — should a markup file really need to know about its own rendering implementation? Wouldn't it be nice to create a separation where markup files exist purely for content, and project configuration is handled elsewhere? This way large structural changes wouldn't necessitate manually editing all affected markup files.
Just a thought. You've set a precedence with
(define-meta template ...)
so I can understand any reluctance to change the approach.Well in my specific case I'm trying to generate html's without
.html
extension and have other poly targets be rendered with relevant extension, eg..pdf
and.md
(and preferably in their own subdirectory).Stashing metadata in the pagetree is not a bad idea (I’ve considered it before). It’s more that having made
metas
(= per-file metadata) andsetup
(= per-directory metadata), I’d prefer to extend those if possible rather than introduce a new location.But you can do this already. Suppose the following project is in a directory
agmck
that's installed as a package:The first source file,
content/example.pm
, can hold the content.The other source files can
require
this file andprovide
itsdoc
andmetas
. (BTW Pollen’s rendering system doesn’t care what#lang
we use, as long as we providedoc
andmetas
). In fact they might all be the same:When you point the project server at this directory, you can browse and preview these source files as usual. (With one caveat: because these files have a dependency not visible to the project server, you would want to turn off render caching and compile caching via
setup
)This is consistent with two idioms already in Pollen: 1) rely on native Racket abstractions whenever possible (like
require
andprovide
) 2) use the filesystem to organize the project.Still, if that’s unsatisfying, nothing prevents you from making a build script that renders files the way you like (everything you need is exposed through
pollen/render
).Thanks for the detailed explanation. This will improve my workflow tremendously. Funnily enough, I'm already using that approach already to concatenate
.css.pm
files together, but it hadn't occurred to me to userequire
andprovide
in otherwise empty files. I'll experiment and perhaps switch to usingpollen/render
calls if my directories become excessively littered with these otherwise empty files.Racket continues to surprise and impress! Feel free to close this ticket and enjoy your Sunday.
I just pushed a small update so that you even leave out
doc
ormetas
from a stub file if you don’t need it, for instance: