Added optional "title" argument to LinkMeta constructor
authorThierry Florac <thierry.florac@onf.fr>
Tue, 29 Jan 2019 10:48:24 +0100
changeset 516 f4bd4666c8d2
parent 515 ec7e001e81bd
child 517 bc05061ceebb
Added optional "title" argument to LinkMeta constructor
src/pyams_skin/metas.py
--- a/src/pyams_skin/metas.py	Thu Jan 24 11:37:56 2019 +0100
+++ b/src/pyams_skin/metas.py	Tue Jan 29 10:48:24 2019 +0100
@@ -138,15 +138,18 @@
 class LinkMeta(object):
     """Link meta header"""
 
-    def __init__(self, rel, type, href):
+    def __init__(self, rel, type, href, title=None):
         self.rel = rel
         self.type = type
         self.href = escape_value(href)
+        self.title = title
 
     def render(self):
-        return '''<link rel="{rel}" type="{type}" href="{href}" />'''.format(rel=self.rel,
-                                                                             type=self.type,
-                                                                             href=self.href)
+        title = ' title="{}"'.format(self.title) if self.title else ''
+        return '''<link rel="{rel}" type="{type}" href="{href}" {title} />'''.format(rel=self.rel,
+                                                                                     type=self.type,
+                                                                                     href=self.href,
+                                                                                     title=title)
 
 
 #