-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend Template Toolkit with a new directive that inherits from INCLUDE directive #59
Comments
I checked the source code and I think it should be possible to add this functionality as configuration option, for example PRE_COMPILE_HOOK. I did some basic testing and it is currently working (see the pull #60). |
Hi Håkon, thanks for the patch. It's a long time since I've written any LaTeX so I might be missing something. My apologies in advance if that's the case. If you need to encode the template name in the For example, here's a
Here's
The output when I run
Does that solve your problem? The other possibility here would be to create your own custom I'm not averse to adding new functionality to TT but I do need to be convinced that it's sufficiently useful to enough people to warrant adding to the core. |
Hi abw. Thanks for the quick response and for letting me know about these options! The macro seems nice, but I think I would try to keep the style Creating a custom provider works fine though! For example, to get the same functionality as the PRE_COMPILE_HOOK suggested in the pull request (
And
The test templates:
and
and finally, the output from running
So the config option PRE_COMPILE_HOOK may not be warranted since the same effect can be achieved by subclassing Anyway, I am glad I discovered this toolkit, it looks very powerful :) |
Hi!
I am considering to use the Template Toolkit to parse LaTeX. I would like to create a system of snippets
similar to the Perl module hierarchy of reusable code. This should help me not repeating paragraphs, sections, or chapters that are similar across several LaTeX documents.
Consider:
main.tex
and
my/math/article/derivation1.tex
So I created a new directive IMPORT that will be a superset of the INCLUDE directive. I would like the IMPORT directive to do the same as INCLUDE but also expand equation labels (and possibly more stuff). So
\label{eq:1}
should be converted to\label{eq:my:math:article:derivation1:1}
, such that the parent document does not have to worry about conflicts in equation labels when importing a snippet.My question is then: Is this a good idea, and is it possible to extend the Template Toolkit with new directives like IMPORT?
The text was updated successfully, but these errors were encountered: