mbutterick / pollen-users

please use https://forums.matthewbutterick.com/c/typesetting/ instead
https://forums.matthewbutterick.com/c/typesetting/
52 stars 0 forks source link

using pollen to generate pollen templates #77

Open v-nys opened 3 years ago

v-nys commented 3 years ago

Hi,

I have a project I'm working on that has three separate templates, all of which share certain elements but which are too different to elegantly handle with conditional code. So I figured I could generate a template by writing .pm source files for the derived templates. But, as far as I can tell, only the null extension and the preprocessor extension are really used for templates.

I got this to work for my scenario, but I pretty much just went in and started tinkering even though I have no real knowledge of the Pollen code base. Essentially, I added a lozenge tag function (which inserts a lozenge character in the output), had the base template include the generated derived template via ◊(select* 'root doc). In the Pollen code base, I made the change in the patch which I have attached.

templatepatch.txt

Would this break anything in the long run? Is there a way of handling this without patching Pollen? If this seems like a valid way of doing things, do I make a pull request?

mbutterick commented 3 years ago

only the null extension and the preprocessor extension are really used for templates.

Right, because otherwise Pollen needs to support templates for templates, which leads to some notational difficulties around the semantics of .

As for your patch, it may fix a legitimate flaw, though I’d like to understand more precisely why the templates are ”too different to elegantly handle with conditional code”. Can you show a simplified example?