-
Notifications
You must be signed in to change notification settings - Fork 14
New doctypes, attribute ordering and attribute escaping #63
Conversation
|
||
@property | ||
def html(self): | ||
return self.html4 or self.html5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern of using properties lets us follow the Ruby Haml code a bit more closely
@@ -56,12 +56,12 @@ def read_element(stream): | |||
|
|||
id_or_class = read_word(stream, DOM_OBJECT_EXTRA_CHARS) | |||
if is_id: | |||
ids.append(id_or_class) | |||
_id = id_or_class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only the last id value is supposed to be used (https://github.com/nyaruka/haml-spec/blob/django-hamlpy/tests.json#L172)
parts = doctype.split() | ||
if parts and parts[0] == "XML": | ||
attr_wrapper = self.compiler.options['attr_wrapper'] | ||
def get_header(self, doctype, options): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<img src='/static/imgs/ibl_logo{{id}}.gif' alt='IBL Logo' /> | ||
<br /> | ||
<img src='/static/imgs/ibl_logo.gif' alt='IBL Logo{{id}}' /> | ||
<img src='/static/imgs/ibl_logo{{id}}.gif' alt='IBL Logo'> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default format is html5 - />
syntax only use for xhtml.
@@ -107,7 +107,7 @@ def test_django_variables(self): | |||
|
|||
# they can be escaped | |||
self._test("%a{'b': '\\\\#{greeting} test', title: \"It can't be removed\"} blah", | |||
"<a b='#{greeting} test' title='It can\\'t be removed'>blah</a>") | |||
"<a b='#{greeting} test' title='It can't be removed'>blah</a>") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTML special chars now escaped by default in attribute values
hamlpy/test/test_compiler.py
Outdated
@@ -209,12 +209,51 @@ def test_invalid_filter(self): | |||
self._test_error(":nosuchfilter\n", "No such filter: nosuchfilter") | |||
|
|||
def test_doctypes(self): | |||
self._test('!!!', '<!DOCTYPE html>', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are copied from the Ruby project
I implemented a test runner for https://github.com/nyaruka/haml-spec/tree/django-hamlpy and these are some fixes to bring us closer to consistency with their spec:
< />
syntax if not using xhtml format%p#id1#id2
should be justid2