diff options
author | Sidnei da Silva <sidnei.da.silva@gmail.com> | 2004-06-22 21:03:48 +0000 |
---|---|---|
committer | Sidnei da Silva <sidnei.da.silva@gmail.com> | 2004-06-22 21:03:48 +0000 |
commit | f7e155110ac29426041c6c55e09a8d864424d887 (patch) | |
tree | 62ecc06c6cf27a5af652f87c8828f7706ea542e6 | |
parent | 2aa287ccd0504a138dab685dc867259d685e93c7 (diff) | |
download | zope-tal-f7e155110ac29426041c6c55e09a8d864424d887.tar.gz |
A small fix (with a test) for a trailing semicolon on i18n:attributes, which would generate a very cryptic compilation error resulting from an indexerror raised inside talgenerator when compiling the page template.
-rw-r--r-- | talgenerator.py | 6 | ||||
-rw-r--r-- | tests/input/test24.html | 3 | ||||
-rw-r--r-- | tests/output/test24.html | 2 |
3 files changed, 10 insertions, 1 deletions
diff --git a/talgenerator.py b/talgenerator.py index 8962908..9f28458 100644 --- a/talgenerator.py +++ b/talgenerator.py @@ -840,7 +840,11 @@ class TALGenerator: def _parseI18nAttributes(i18nattrs, position, xml): d = {} - for spec in i18nattrs.split(";"): + # Filter out empty items, eg: + # i18n:attributes="value msgid; name msgid2;" + # would result in 3 items where the last one is empty + attrs = filter(None, i18nattrs.split(";")) + for spec in attrs: parts = spec.split() if len(parts) > 2: raise TALError("illegal i18n:attributes specification: %r" % spec, diff --git a/tests/input/test24.html b/tests/input/test24.html index 5f48f49..6d53984 100644 --- a/tests/input/test24.html +++ b/tests/input/test24.html @@ -7,3 +7,6 @@ <input i18n:attributes=" name message-id; attr input-attr "> + +<input i18n:attributes=" name message-id; + attr input-attr;"> diff --git a/tests/output/test24.html b/tests/output/test24.html index f8ef747..8dbfba3 100644 --- a/tests/output/test24.html +++ b/tests/output/test24.html @@ -3,3 +3,5 @@ <input name="MESSAGE-ID"> <input name="MESSAGE-ID" attr="INPUT-ATTR"> + +<input name="MESSAGE-ID" attr="INPUT-ATTR"> |