diff --git a/CHANGELOG.md b/CHANGELOG.md
index 03b1b67..3e66120 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,12 @@
-21-06-2024
+15-06-2025 - v1.0.1
+
+* Fixed bug in attribute parsing for tags with multiple attributes
+* Improved regex parsing to handle quoted attribute values correctly
+* Added comprehensive test for multi-attribute tags (e.g., meta name='viewport' initial-scale='1')
+* Renamed .skml files to .html.trim and updated all test references
+* Added sub-template examples with user objects in examples directory
+
+21-06-2024 - v1.0.0
* make trim-template available on PyPI
diff --git a/pyproject.toml b/pyproject.toml
index fabe502..d6728d5 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "trim-template"
-version = "1.0.0"
+version = "1.0.1"
description = "A templating engine inspired by Ruby's Slim template engine"
authors = ["David Kelly"]
license = "MIT License"
@@ -10,7 +10,7 @@ keywords = ["template", "trim", "engine", "html"]
[project]
name = "trim-template"
-version = "0.1.0"
+version = "1.0.1"
description = "A templating engine inspired by Ruby's Slim template engine"
authors = [
{name = "David Kelly", email = "info@futuresbright.com"}
diff --git a/setup.py b/setup.py
index 22e1e93..faa2cd6 100644
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,7 @@
setup(
name='trim-template',
- version='1.0',
+ version='1.0.1',
packages=['trim_template'],
entry_points={
'console_scripts': [
diff --git a/tests/test_tag_attributes.py b/tests/test_tag_attributes.py
new file mode 100644
index 0000000..44d43c7
--- /dev/null
+++ b/tests/test_tag_attributes.py
@@ -0,0 +1,12 @@
+from trim_template.trim import TrimTemplate
+
+template = """
+meta name='viewport' initial-scale='1'
+meta name='description' content='A description of the page'
+"""
+
+def test_tag_attributes():
+ tmpl = TrimTemplate(template, pretty=False)
+ output = tmpl.render()
+
+ assert output == ''
\ No newline at end of file
diff --git a/trim_template/node.py b/trim_template/node.py
index 75e5c94..9a342d0 100644
--- a/trim_template/node.py
+++ b/trim_template/node.py
@@ -20,7 +20,8 @@ def __init__(self, indentation, line = None):
return
self.line = line.strip()
- self.parts = self.line.split(" ")
+ # Use regex to split on key='value', key="value", or key=value, or tag
+ self.parts = re.findall(r"[^ \t]+='[^']*'|[^ \t]+=\"[^\"]*\"|[^ \t]+", self.line)
if self.line == '':
return
@@ -109,8 +110,15 @@ def parse_attributes(self):
for a in (self.parts[1:]):
if '=' in a:
- key, val = a.split('=')
- self.attributes[key] = val.strip('"').strip("'")
+ equal_pos = a.find('=')
+ key = a[:equal_pos].strip('"\'')
+ val = a[equal_pos + 1:]
+
+ # Only strip quotes if both ends are quoted
+ if (val.startswith('"') and val.endswith('"')) or (val.startswith("'") and val.endswith("'")):
+ val = val[1:-1]
+
+ self.attributes[key] = val
else:
self.text += a + " "
@@ -133,4 +141,4 @@ def has_attributes(self):
return self.attributes != []
def attributes(self):
- return ' '.join(self.attributes)
+ return ' '.join(f'{k}="{v}"' for k, v in self.attributes.items())