brechtm / rinohtype

The Python document processor
http://www.mos6581.org/rinohtype
GNU Affero General Public License v3.0
500 stars 60 forks source link

How do you use a custom template? #390

Open laxnash opened 1 year ago

laxnash commented 1 year ago

The documentation lays out how to create a new template by subclassing an existing template like article. http://www.mos6581.org/rinohtype/master/templates.html However, it doesnt say how to access the new template you created. In the source directory I have the conf.py file, which specifies the project-template.rtt file I created and the newtemplate.py file I created to subclass the article template. When I try to specify the new template I created in the project-template.rtt file it gives me an error saying it cant find my template. Is there a specific place I have to put the template? Is there a script I have to run to get rhinotype to see my template?

brechtm commented 1 year ago

You have to register your custom template using the register_template() function. 'my_template' in the example below is the name by which you can then reference it in your .rtt file.

from rinoh import register_template

register_template('my_template', MyDocumentTemplate)

(Please don't close this issue; I'll close it once the documentation has been updated to cover this)