Quote:
Originally Posted by chaley
@capink: do you see a use for constructing your own python formatter context object and passing it to the formatter? One I thought of is what you mentioned in the development thread: adding "helper methods" to the context.
The mechanism would work like globals. If an instance isn't provided (a named parameter) then the formatter would construct one. If one is provided then it will be used, with the lifetime controlled by you.
|
Yes. Actually I was thinking about this. Before you mentioned this I thought of two ways:
- Use the chain object that I would smuggle inside the globals dict for defining these methods. Your proposal is much cleaner way of doing this.
- Monkey patching calibre's context class. I am not sure how clean/desirable this would be. But if offers me one thing none of the other options do; the ability to use any plugin defined helper functions in calibre's template search.