{"id":15067826,"url":"https://github.com/ehamiter/django-whiff","last_synced_at":"2026-01-05T12:40:19.720Z","repository":{"id":257659275,"uuid":"859008675","full_name":"ehamiter/django-whiff","owner":"ehamiter","description":"A simple Django template tag that combines the functionality of the `with` and `if` tags","archived":false,"fork":false,"pushed_at":"2024-09-18T00:02:55.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-03T04:11:30.269Z","etag":null,"topics":["django","python","templatetags"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/django-whiff/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ehamiter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-17T23:16:29.000Z","updated_at":"2024-09-18T16:55:43.000Z","dependencies_parsed_at":"2024-09-18T01:11:19.982Z","dependency_job_id":"f289d000-77ca-445b-8868-263f8abd5488","html_url":"https://github.com/ehamiter/django-whiff","commit_stats":null,"previous_names":["ehamiter/django-whiff"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehamiter%2Fdjango-whiff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehamiter%2Fdjango-whiff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehamiter%2Fdjango-whiff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehamiter%2Fdjango-whiff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ehamiter","download_url":"https://codeload.github.com/ehamiter/django-whiff/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239126510,"owners_count":19586101,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","python","templatetags"],"created_at":"2024-09-25T01:27:41.248Z","updated_at":"2025-11-01T15:30:21.134Z","avatar_url":"https://github.com/ehamiter.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# django-whiff\n\n`django-whiff` is a simple Django template tag that combines the functionality of the `with` and `if` tags, inspired by the Python walrus operator (`:=`). It allows you to assign a variable and immediately check if it is truthy, rendering content if it is.\n\n## Example\n\n```django\n{% load whiff %}\n\n  {% whiff current_user as user %}\n    \u003ch1\u003eWelcome back, {{ user.first_name }} {{ user.last_name }}!\u003c/h1\u003e\n    \u003cp\u003eYour last login was on {{ user.last_login|date:\"F j, Y, g:i a\" }}.\u003c/p\u003e\n\n      \u003ch2\u003eYour Profile\u003c/h2\u003e\n      \u003cul\u003e\n        \u003cli\u003eEmail:  {{ user.email }}\u003c/li\u003e\n        \u003cli\u003eJoined: {{ user.date_joined|date:\"F j, Y\" }}\u003c/li\u003e\n        \u003cli\u003eBio:    {{ user.bio }}\u003c/li\u003e\n      \u003c/ul\u003e\n  {% endwhiff %}\n```\n\n## Features\n\n- Combines `with` and `if` in a single template tag.\n- Simplifies template logic by reducing the need for nested tags.\n- Easy to use and integrate into existing Django projects.\n\n## Caveats\n\n- Not a great contender to replace multiple pipes or conditions in an existing template tag\n\n## Installation\n\nYou can install `django-whiff` via pip:\n\n```bash\npip install django-whiff\n```\n\n## Usage\n\nOnce installed, add `django_whiff` to your `INSTALLED_APPS` in your Django settings:\n\n```python\nINSTALLED_APPS = [\n    ...\n    'django_whiff',\n    ...\n]\n```\n\n\u003e Note *the underscore*, not hyphen.\n\n### How It Works\n\n- The `whiff` tag assigns the value of `some_obj` to `obj`.\n- If `some_obj` is truthy, the content inside the `whiff` block is rendered.\n- If `some_obj` is falsey, nothing is rendered.\n\n\n## Tests\n```\npython -m unittest discover -s tests\n```\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.\n\n## Contributing\n\nContributions are welcome! If you find a bug or have a feature request, please open an issue on the [GitHub repository](https://github.com/ehamiter/django-whiff).\n\n## Acknowledgements\n\nInspired by the Python walrus operator (`:=`) and the need for cleaner, more concise template logic.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehamiter%2Fdjango-whiff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fehamiter%2Fdjango-whiff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehamiter%2Fdjango-whiff/lists"}