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

Allow .yml as YAML file extension #161

Closed
tbrlpld opened this issue Dec 21, 2021 · 1 comment · Fixed by #169
Closed

Allow .yml as YAML file extension #161

tbrlpld opened this issue Dec 21, 2021 · 1 comment · Fixed by #169
Labels
enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@tbrlpld
Copy link
Collaborator

tbrlpld commented Dec 21, 2021

Issue Summary

When defining template context files (the YAML) files, these are only recognised when they use the full .yaml extension.

When using the shorter .yml extension the template is not picking up the context file.

This can be very confusing.

Steps to Reproduce

  1. Setup a project with django-patter-library enable
  2. Create a template test.html in one of the directories observed by django-pattern-library with the content
{{ test_var }}
  1. Create a context file test.yaml next to the template with the content
context:
  test_var: Test content
  1. Open the template in the patter library and observe that you see "Test content"
  2. Rename the context file mv test.yaml test.yml
  3. Open the template in the patter library and observe that you see nothing. The context is not rendered anymore.
@thibaudcolas thibaudcolas added enhancement New feature or request good first issue Good for newcomers labels Dec 21, 2021
@thibaudcolas thibaudcolas added this to the Nice to have milestone Dec 21, 2021
@thibaudcolas
Copy link
Member

thibaudcolas commented Dec 21, 2021

👍 I like the idea.

It seems this would be pretty simple to do here: https://github.com/torchbox/django-pattern-library/blob/main/pattern_library/utils.py#L148. My preference would be for us to attempt to load the .yml file if .yaml doesn’t load, so projects can mix and match extensions.

PR welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants