Defining frequently used HTML fragments as constants?

15 views
Skip to first unread message

Spiff

unread,
Oct 14, 2019, 12:27:42 PM10/14/19
to Django users
Hi, I'm reading up on how to properly output html. Let's say I have a row for a table that would be useful in more than one method, is it a good idea to define this as a constant, like so?
MONTH_ROW = '<tr><td><a href="{0}">{1}</a></td></tr>\n'

Julio Cojom

unread,
Oct 14, 2019, 12:33:36 PM10/14/19
to django...@googlegroups.com
I guess it will be in your views , if it's used in more than 1 def maybe you can use a def who return your variable and use it in for loop to call it many times.


El lun., 14 de octubre de 2019 10:27 a. m., Spiff <flab...@hotmail.de> escribió:
Hi, I'm reading up on how to properly output html. Let's say I have a row for a table that would be useful in more than one method, is it a good idea to define this as a constant, like so?
MONTH_ROW = '<tr><td><a href="{0}">{1}</a></td></tr>\n'

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/49fb166f-4f6d-44a7-a57a-c575494e6394%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages