-
Notifications
You must be signed in to change notification settings - Fork 132
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
Add templating to publishing functionality #515
Comments
Hi Wojciech I realize that it would be a very useful feature. I've been using something like that, for communication documents (but without Jinja, your approach looks far more sound) As soon as a I get #507 done, count on some help on this :) Leandro |
Hi! As promissed, started exploring this feature along with @lucasd92, now that #507 is finally waiting to be merged, (maybe @jacebrowning ?) :)
Looks promissing! First pitfall we came across: Jinja2's output can be consumed as an iterator, and Doorstop expects that. Thusly allowing for iterator chains and coroutines. But it looks like iterators composition is lost in Bottle.Jinja2Template. In spite of the description saying "Get a rendered template as a string iterator" it calls render() instead of generate() with no altarnetive. Workarounded here, somewhat piercing Bottle's abraction. Best regards, |
I'm also looking into options to use customised reporting templates with Doorstop. Given the challenges @eterX outlines above, would it make more sense to build a separate, template-based Doorstop reporter and leave the current Doorstop reporting as is? Doorstop's YAML data format is elegant and extensible, and I think the extensibility is where the magic is. For example, I'm currently using Doorstop with custom requirements fields that I'll want to use every time (e.g. classifying each requirement using FURPS+), but also with fields that will change from project to project. These could include e.g.
Given how well Doorstop's extensibility supports this approach, it makes sense to have reporting templates be similarly customisable to specific use cases. There's also Doorstop APIs that give access to all the custom fields, which make it easier still to implement. I'll knock something simple together and post it here as an example |
Jinja is a pretty handy templating engine for Python. This approach lets you use Jinja templates with doorstop:
Inside your Jinja template, you can then use something like
to present your doorstop data. Note that you might need to escape your doorstop data if it contains certain characters, which is why I've got {{ dependency_tree | e }}. Note also that adding the Markdown extension to Jinja lets Jinja work with Markdown content, which you might be using inside your doorstop YAMLs. Hopefully I haven't cut down this code too much to make it understandable. Now I just need to work out how to walk the tree of linked documents using the doorstop scripting interface... |
Would it be possible to specify the publishing template within the .doorstop.yml file for each document/type? |
@wojciechczerniak Could you have a look at version v.3.0b12 and see if you think this version solves this issue? |
Hello,
This time a feature request.
Problem
I've seen that there are few requests/issues with customization of the Markdown output:
publish
#166And I would have few others requirements:
But IMO a change from string building to one of the templating languages may solve all of the above in a one go
Solution idea
I think Jinja2 is the number one for Python libraries? With a template and an ability to use our own fixing all of the above issues would be just a matter of customization with
--template my-markdown.jinja2
Remove hard-coded string building in HTML publisher:
doorstop/doorstop/core/publisher.py
Lines 165 to 167 in a770dc4
and Markdown markdown publisher:
doorstop/doorstop/core/publisher.py
Lines 399 to 409 in a770dc4
With Jinja2 templates defaulting to whatever is in those methods:
AND allow the
--template
arg for all output formats.Use cases
You want Frontmatter/YAML headers in Markdown #295, just add them to the template:
Footer maybe as in #166? Add it at the end:
The text was updated successfully, but these errors were encountered: