From b3c9dd58f501575a4f8b1078167d27854a80f9c8 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 26 Nov 2017 02:38:39 -0800 Subject: [PATCH] Allow custom innertext besides just the tag's name. --- .../etiquette_flask/templates/tag_object.html | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/frontends/etiquette_flask/templates/tag_object.html b/frontends/etiquette_flask/templates/tag_object.html index 5f670ae..96cbe92 100644 --- a/frontends/etiquette_flask/templates/tag_object.html +++ b/frontends/etiquette_flask/templates/tag_object.html @@ -2,6 +2,9 @@ tag: The Tag object extra_classes: Space-separated string, if you want more than "tag_object". + innertext: + A string to use as the innertext. + Otherwise, will use the name based on the other parameters. link: None = no link, just a 'search' = link to /search?tag_musts=tagname @@ -14,7 +17,7 @@ If the tag's own name can't find under the limit, characters are dropped from the right. qualified_name: - True: Use the qualified name as the innerhtml + True: Use the qualified name as the innertext False: Use the basic name with_alt_description: True: Include the description in the alt text @@ -24,6 +27,7 @@ {% macro tag_object( tag, extra_classes="", + innertext=None, link='search', max_len=None, qualified_name=True, @@ -42,13 +46,15 @@ {%- else -%} {{' '}}href="{{search}}" {%- endif -%} - {{' '}}target="_blank" class="tag_object {{extra_classes}}" + {{' '}}target="_blank" {%- else -%} {% set closing="" %} -{%- if qualified_name -%} - {{tag.qualified_name(max_len=max_len)}} +{%- if innertext is not none -%} + {{innertext}} {%- else -%} - {%- if max_len is not none -%} - {{tag.name[:max_len]}} + {%- if qualified_name -%} + {{tag.qualified_name(max_len=max_len)}} {%- else -%} - {{tag.name}} + {%- if max_len is not none -%} + {{tag.name[:max_len]}} + {%- else -%} + {{tag.name}} + {%- endif -%} {%- endif -%} -{%- endif -%} +{% endif %} {{- closing|safe -}} {% endmacro %}