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

Accessing trailers in template #108

Open
viktoradavid opened this issue Nov 15, 2018 · 3 comments
Open

Accessing trailers in template #108

viktoradavid opened this issue Nov 15, 2018 · 3 comments

Comments

@viktoradavid
Copy link

Hi, the doc says it is possible to use trailers. However, can custom trailers really be accessed from the templates? I didn't manage to make it work and it doesn't seem like this is supported. Should the doc be updated? Thanks!

@vaab
Copy link
Owner

vaab commented Nov 15, 2018

Hi, thanks for your interest in Gitchangelog and your time to report this.

Indeed, the README doesn't cover access to custom trailers. I'll keep this thread open until this is fixed.

Meanwhile, you can use:
https://github.com/vaab/gitchangelog/blob/master/src/gitchangelog/gitchangelog.py#L791-L823

As a quick documentation how to use them. Knowing that template data can access directly commit object through

https://github.com/vaab/gitchangelog/blob/master/src/gitchangelog/gitchangelog.py#L1600

As you see, commit is the commit object, along the author, subject and body keys provided in the data structure that templates receives (as documented properly in the README.rst for these last 3 keys).

I'm afraid that all that is not documented properly. I hope that this is helping you getting access to what you need.

@viktoradavid
Copy link
Author

Hi, I really appreciate your help!
I was checking the sources you linked during my first investigation. However, I missed one thing while working with sample mako template - you basically need to use commit['commit'] to acces trailers.
In case someone gets here in the future - to get e.g. trailer Subscribers: xyz, you need to use commit['commit'].trailer_subscribers.

Unfortunately, this does not solve my issue, since trailers we're working with contain spaces in the key, e.g. Maniphest Tasks: xyz (not sure if that's allowed in the specs, but that's what Phabricator does). I could prepare a PR to also allow spaces, but I'm not sure they are allowed..

Thanks again for a very helpful post and project!

@vaab
Copy link
Owner

vaab commented Dec 21, 2018

Thanks for your feedback on this particular use case. I'll keep this issue open to keep track of a feature allowing access to trailer keys more traditionally (simple dict).

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

No branches or pull requests

2 participants