@@ -100,9 +100,6 @@ def _convert_bss_link(self, file_link):
100100 In bss : file_type/app_name (ex: js/home)
101101 In django : app_name/file_type (ex: home/js)
102102 """
103- if file_link .startswith ("http" ):
104- return file_link
105-
106103 #Remove file root
107104 if file_link .startswith ("/" ):
108105 file_link = file_link [1 :]
@@ -122,19 +119,29 @@ def _replace_static_links(self, tag_name):
122119
123120 e.g. img, script etc.
124121 """
125- for element in self .tree .select (tag_name ):
126- href = element .attrs .get ("href" )
127- src = element .attrs .get ("src" )
122+ link_allowed_attributes = ["href" , "src" ]
128123
129- static_template = '{{% static "{}" %}}'
124+ def find_ressource_attribute (element_attributes ):
125+ """
126+ Find which attribute is used to point to a ressource.
127+ Return used attribute, and his value.
128+ """
129+ for attribute in link_allowed_attributes :
130+ value = element_attributes .get (attribute )
131+ if value :
132+ return attribute , value
133+
134+ static_template = '{{% static "{}" %}}'
135+
136+ for element in self .tree .select (tag_name ):
137+ attribute , link = find_ressource_attribute (element .attrs )
130138
131- if src and not src .startswith ("http" ):
132- src = self ._convert_bss_link (src )
133- element .attrs ["src" ] = static_template .format (src )
139+ if link .startswith ("http" ):
140+ continue
134141
135- if href and not href . startswith ( "http" ):
136- href = self . _convert_bss_link ( href )
137- element . attrs [ "href" ] = static_template .format (href )
142+ converted_link = self . _convert_bss_link ( link )
143+ element . attrs [ attribute ] = \
144+ static_template .format (converted_link )
138145
139146 def _replace_ref (self ):
140147 """
0 commit comments