diff --git a/snipts/templates/snipts/snipt-list.html b/snipts/templates/snipts/snipt-list.html index b319ea4..6cdb768 100644 --- a/snipts/templates/snipts/snipt-list.html +++ b/snipts/templates/snipts/snipt-list.html @@ -19,7 +19,26 @@ {{ snipt.stylized|safe }} {% else %} - {{ snipt.stylized|safe }} + {% if 'linenos' not in snipt.stylized %} + + + + + + + +
+
+
+                                                {% generate_line_numbers for snipt.line_count %}
+                                            
+
+
+ {{ snipt.stylized|safe }} +
+ {% else %} + {{ snipt.stylized|safe }} + {% endif %} {% endif %} {% if snipt.line_count > 8 and not detail and 'snipt-expand' not in snipt.tags_list %} diff --git a/snipts/templatetags/snipt_tags.py b/snipts/templatetags/snipt_tags.py index b3277a8..85bced6 100644 --- a/snipts/templatetags/snipt_tags.py +++ b/snipts/templatetags/snipt_tags.py @@ -47,6 +47,14 @@ def get_lexers(context, asvar): context[asvar] = get_lexers_list() return '' +@tag(register, [Constant('for'), Variable()]) +def generate_line_numbers(context, line_numbers): + html = '' + + for i in range(1, line_numbers + 1): + html = html + '{}'.format(i) + + return html @register.filter def md5(string):