From: Jean-Christophe Beaupré Date: Thu, 4 Dec 2014 17:08:08 +0000 (-0500) Subject: nitdoc: Escape attributes. X-Git-Tag: v0.7~79^2 X-Git-Url: http://nitlanguage.org nitdoc: Escape attributes. Signed-off-by: Jean-Christophe Beaupré --- diff --git a/src/doc/doc_templates.nit b/src/doc/doc_templates.nit index c4729a5..353ecdf 100644 --- a/src/doc/doc_templates.nit +++ b/src/doc/doc_templates.nit @@ -841,6 +841,16 @@ end # A HTML tag attribute # `` +# +# ~~~nit +# var attr: TagAttribute +# +# attr = new TagAttribute("foo", null) +# assert attr.write_to_string == " foo=\"\"" +# +# attr = new TagAttribute("foo", "bar<>") +# assert attr.write_to_string == " foo=\"bar<>\"" +# ~~~ class TagAttribute super Template @@ -850,9 +860,10 @@ class TagAttribute redef fun rendering do var value = self.value if value == null then - add(" {name}") + # SEE: http://www.w3.org/TR/html5/infrastructure.html#boolean-attributes + add " {name.html_escape}=\"\"" else - add(" {name}=\"{value}\"") + add " {name.html_escape}=\"{value.html_escape}\"" end end end