A parser for HTML templates.
Project description
HTML Template Parser
Modified version of Python's HTMLParser for HTML template parsing
🤔 For What?
The is an HTML template parser. It is a modified version of Python's HTMLParse library, expanded to handle template tags.
Currently Supported
- Comments
- Template tags (if/for/...)
💾 Install
pip install html-template-parser
# or
poetry add html-template-parser
✨ How to Use
A basic usage example is remarkably similar to Python's HTMLParser:
from HtmlTemplateParser import Htp
class MyHTMLParser(Htp):
def handle_starttag(self, tag, attrs):
print("Encountered a start tag:", tag)
def handle_endtag(self, tag):
print("Encountered an end tag :", tag)
def handle_data(self, data):
print("Encountered some data :", data)
parser = MyHTMLParser()
parser.feed('<html><head><title>Test</title></head>'
'<body><h1>Parse me!</h1></body></html>')
🏷 Function Naming Conventions
Comments
- comment
<!-- -->
- comment_curly_hash
{# data #}
- comment_curly_exlaim
{{! data }}
- comment_curly_exlaim_dash
{{!-- data }}
- comment_curly_perc
{% comment "attrs" %}data {% endcomment %}
- comment_at_star
@* data *@
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for html-template-parser-1.1.0a1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b11fff085c65b26fe568b195007814cd91b14002a827e8ef9910b8867ec2154f |
|
MD5 | 7e1d04cefbd23f2ec3e71f55ebbecd80 |
|
BLAKE2b-256 | c2e41c0b3bd8286d97330399ca636de27fb6433f83e918291a64645b35af5947 |
Close
Hashes for html_template_parser-1.1.0a1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c17b08235b0bdd5038db9632296ecd0d93586aef5fb8c9c0f60f9ff449c3682 |
|
MD5 | bbc31cd10cd64837c2d2e27bfbbf5002 |
|
BLAKE2b-256 | d272cc40ae20da63d5a73fc4bb838f4d87c012d7edefa7b85c914a359b136da2 |