Skip to content
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

Item templates #9

Closed
ociu opened this issue Apr 13, 2016 · 1 comment
Closed

Item templates #9

ociu opened this issue Apr 13, 2016 · 1 comment
Milestone

Comments

@ociu
Copy link
Owner

ociu commented Apr 13, 2016

Instead of the annoying admonition node formatting, provide a template mechanism so user can decide how to format items, in a similar way to how matplotlib plot directive does.

In order to allow different templates in the same project, regexps and/or class options could be used to decide which items a template should be applied to.

Example template: defining items as term-definition pairs, with highlighted caption as first definition line:

"""
{{ item_id }}
    **{{ item_caption }}**
    {{ item_body }}
"""
@ociu ociu added this to the 0.2.0 milestone Apr 13, 2016
ociu added a commit that referenced this issue May 2, 2016
This is a first step towards custom templates. Should be straightforward
to implement now.

refs #9
@ociu ociu closed this as completed in a31affa Jun 5, 2016
@ociu
Copy link
Owner Author

ociu commented Jun 5, 2016

Finally the example/default template had to be slightly different, in order to be correctly rendered:

{{ id }}
{%- if caption %}
    **{{ caption }}**
{% endif %}
    {{ content|indent(4) }}

Multi-line strings have to be explicitly indented, and caption treated as optional with if statements. Input data (id, caption, content...) is exactly the same used internally to store item information.

A lot has to be written on this topic... Templating is definitely not easy, extreme care has to be taken and Jinja2 templating well understood. Will try to explain it further in the README file and make some impressing examples (as the results can be absolutely amazing :)). As a summary, Instead of giving the traceabiity extension more power to handle templates, I decided to keep it as simple as possible, and give the user full freedom in the template, giving as input all the item information. A user can do magic just within one template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant