To get attribute values from a node you can use the []
method. For example:
media_replace(match['data_id'], match['data_gallery'])
To replace the node, use the replace
or swap
methods (assuming media_replace
returns a string or other compatible object):
new_html = media_replace(...)
match.replace(new_html)