{"id":18400405,"url":"https://github.com/djlint/html-template-parser","last_synced_at":"2026-03-05T21:05:05.560Z","repository":{"id":37964740,"uuid":"492873163","full_name":"djlint/html-template-parser","owner":"djlint","description":"A parser for HTML templates.","archived":false,"fork":false,"pushed_at":"2024-10-08T12:16:10.000Z","size":1064,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-31T00:39:11.324Z","etag":null,"topics":["django","handlebars","html","html-template","jinja","mustache","parser","python","template","twig"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/djlint.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":"2022-05-16T14:34:00.000Z","updated_at":"2024-12-30T22:26:58.000Z","dependencies_parsed_at":"2024-12-24T11:41:40.161Z","dependency_job_id":"a45b5dca-f3dc-43a3-9262-682202078e6f","html_url":"https://github.com/djlint/html-template-parser","commit_stats":null,"previous_names":["djlint/html-template-parser"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/djlint/html-template-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djlint%2Fhtml-template-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djlint%2Fhtml-template-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djlint%2Fhtml-template-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djlint%2Fhtml-template-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/djlint","download_url":"https://codeload.github.com/djlint/html-template-parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djlint%2Fhtml-template-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30149951,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T16:58:46.102Z","status":"ssl_error","status_checked_at":"2026-03-05T16:58:45.706Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","handlebars","html","html-template","jinja","mustache","parser","python","template","twig"],"created_at":"2024-11-06T02:32:45.802Z","updated_at":"2026-03-05T21:05:05.507Z","avatar_url":"https://github.com/djlint.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eHTML Template Parser\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003eModified version of Python's HTMLParser for HTML template parsing\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://codecov.io/gh/Riverside-Healthcare/html-template-parser\"\u003e\n    \u003cimg src=\"https://codecov.io/gh/Riverside-Healthcare/html-template-parser/branch/master/graph/badge.svg?token=Chqq9Mai1h\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/Riverside-Healthcare/html-template-parser/actions/workflows/test.yml\"\u003e\n    \u003cimg src=\"https://github.com/Riverside-Healthcare/html-template-parser/actions/workflows/test.yml/badge.svg\" alt=\"Test Status\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.codacy.com/gh/Riverside-Healthcare/html-template-parser/dashboard?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=Riverside-Healthcare/html-template-parser\u0026amp;utm_campaign=Badge_Grade\"\u003e\n    \u003cimg src=\"https://app.codacy.com/project/badge/Grade/43736e5b780a49d88d8ce588f5cfb9bc\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://pepy.tech/project/html-template-parser\"\u003e\n    \u003cimg src=\"https://static.pepy.tech/badge/html-template-parser\" alt=\"Downloads\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://pypi.org/project/html-template-parser/\"\u003e\n    \u003cimg src=\"https://badgen.net/pypi/v/html-template-parser\" alt=\"Pypi Version\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## 🤔 For What?\n\nThe is an HTML template parser. It is a modified version of Python's HTMLParse library, expanded to handle template tags.\n\n## 💾 Install\n\n```sh\npip install html-template-parser\n\n# or\n\npoetry add html-template-parser\n```\n\n## ✨ How to Use\n\nA basic usage example is remarkably similar to Python's HTMLParser:\n\n```py\nfrom HtmlTemplateParser import Htp\nfrom HtmlTemplateParser import AttributeParser\n\n\nclass MyAttributeParser(AttributeParser):\n    def handle_starttag_curly_perc(self, tag, attrs, props):\n        print(\"starttag_curly_perc\", tag, attrs, props)\n\n        # get the position of the element relative to the original html\n        print(self.getpos())\n\n        # get the original html text\n        print(self.get_element_text())\n\n    def handle_endtag_curly_perc(self, tag, attrs, props):\n        print(\"endtag_curly_perc\", tag, attrs, props)\n\n    def handle_value(self, value):\n        print(\"value\", value)\n\n\nclass MyHTMLParser(Htp):\n    def handle_starttag(self, tag, attrs):\n        print(\"Encountered a start tag:\", tag)\n        print(self.getpos())\n\n        MyAttributeParser(attrs).parse()\n\n    def handle_endtag(self, tag):\n        print(\"Encountered an end tag :\", tag)\n\n    def handle_data(self, data):\n        print(\"Encountered some data  :\", data)\n\nparser = MyHTMLParser()\nparser.feed('\u003chtml\u003e\u003chead\u003e\u003ctitle\u003eTest\u003c/title\u003e\u003c/head\u003e'\n            '\u003cbody {% if this %}ok{% endif %}\u003e\u003ch1\u003eParse me!\u003c/h1\u003e\u003c/body\u003e\u003c/html\u003e')\n\n```\n\n## 🏷 Function Naming Conventions\n\n### Comments\n\n- comment `\u003c!-- --\u003e`\n- comment_curly_hash `{# data #}`\n- comment_curly_two_exlaim `{{! data }}`\n- starttag_comment_curly_perc `{% comment \"attrs\" %}`\n- endtag_comment_curly_perc `{% endcomment %}`\n- comment_at_star `@* data *@`\n\n### Structure\n\n- startendtag `\u003c /\u003e`\n- starttag `\u003c`\n- starttag_curly_perc `{% ... %}`\n- starttag_curly_two_hash `{{#...}}`\n- starttag_curly_four `{{{{...}}}}`\n\n- endtag `\u003c.../\u003e`\n- endtag_curly_perc `{% end.. %}`\n- endtag_curly_two_slash `{{/...}}`\n- endtag_curly_four_slash ` {{{{/...}}}}`\n\n### Data and Other\n\n- unknown_decl\n- charref\n- entityref\n- data\n- curly_two `{{ ... }}`\n- slash_curly_two `\\{{ ... }}`\n- curly_three `{{{ ... }}}`\n- decl\n- pi\n\n\n### Modifiers\n\nModifiers such as `~`, `!--`, `-`, `+`, `\u003e` will show up as props on the tags.\n\n### Attributes\n\nAttributes are passed from the Htp as a complete string to be parsed with the attribute parser.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjlint%2Fhtml-template-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdjlint%2Fhtml-template-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjlint%2Fhtml-template-parser/lists"}