Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Websites UFRPE
django-dsgov
Commits
f28e477a
Commit
f28e477a
authored
Jul 03, 2025
by
Eduardo Silva
Browse files
alteracao na tag de footer
#5
parent
671b9985
Changes
2
Show whitespace changes
Inline
Side-by-side
dsgov/templatetags/footer_tags.py
→
dsgov/templatetags/
br_
footer_tags.py
View file @
f28e477a
...
...
@@ -3,6 +3,7 @@ from django.utils.html import format_html
from
django.templatetags.static
import
static
from
django.template.loader
import
render_to_string
from
django.utils.safestring
import
mark_safe
from
django.template.base
import
token_kwargs
register
=
template
.
Library
()
...
...
@@ -161,22 +162,32 @@ def do_footer_social_section(parser, token):
Esta tag agora lida com TODA a seção social,
incluindo o layout de linha e colunas, resolvendo o problema de coordenação.
"""
bits
=
token
.
split_contents
()
kwargs
=
token_kwargs
(
bits
[
1
:],
parser
)
nodelist
=
parser
.
parse
((
'end_br_footer_social_section'
,))
parser
.
delete_first_token
()
return
SocialSectionNode
(
nodelist
)
return
SocialSectionNode
(
nodelist
,
kwargs
)
class
SocialSectionNode
(
template
.
Node
):
def
__init__
(
self
,
nodelist
):
def
__init__
(
self
,
nodelist
,
kwargs
):
self
.
nodelist
=
nodelist
self
.
kwargs
=
kwargs
def
render
(
self
,
context
):
# A tag filha vai popular essas listas no contexto
# Pega o título se tiver, senão usa padrão
title
=
self
.
kwargs
.
get
(
'title'
)
if
title
:
title
=
title
.
resolve
(
context
)
else
:
title
=
"Redes Sociais"
# Coleta os dados
social_links
=
[]
assign_images
=
[]
with
context
.
push
(
social_links
=
social_links
,
assign_images
=
assign_images
):
self
.
nodelist
.
render
(
context
)
#
Agora construímos o HTML com os da
dos co
letado
s
#
HTML
dos
í
co
nes e imagen
s
social_links_html
=
''
.
join
([
format_html
(
'<a class="br-button circle" href="{}" aria-label="{}"><i class="fab {}" aria-hidden="true"></i></a>'
,
link
[
'href'
],
link
[
'aria_label'
],
link
[
'icone'
]
...
...
@@ -192,13 +203,14 @@ class SocialSectionNode(template.Node):
<div class="row align-items-end justify-content-between py-5">
<div class="col">
<div class="social-network">
<div class="social-network-title">
Redes Sociais
</div>
<div class="social-network-title">
{}
</div>
<div class="d-flex">{}</div>
</div>
</div>
<div class="col assigns text-right">{}</div>
</div>
</div>'''
,
title
,
mark_safe
(
social_links_html
),
mark_safe
(
assign_images_html
)
)
...
...
tests/django_dsgov_test1/templates/examples_footer.html
View file @
f28e477a
{% extends "dsgov/base.html" %}
{% load footer_tags %}
{% load
br_
footer_tags %}
{% load static %}
{% block title %}
...
...
@@ -80,7 +80,7 @@
{% end_br_footer_columns_group %}
{# Seção de Redes Sociais que organiza suas próprias colunas e linhas #}
{% br_footer_social_section %}
{% br_footer_social_section
title="Nossas Redes"
%}
{% br_footer_rede_social href="#" icone="fa-facebook-f" aria_label="Facebook" %}
{% br_footer_rede_social href="#" icone="fa-twitter" aria_label="Twitter" %}
{% br_footer_rede_social href="#" icone="fa-linkedin-in" aria_label="LinkedIn" %}
...
...
@@ -171,7 +171,7 @@
{% end_br_footer_columns_group %}
{# Seção de Redes Sociais que organiza suas próprias colunas e linhas #}
{% br_footer_social_section %}
{% br_footer_social_section
title="Nossas Redes"
%}
{% br_footer_rede_social href="#" icone="fa-facebook-f" aria_label="Facebook" %}
{% br_footer_rede_social href="#" icone="fa-twitter" aria_label="Twitter" %}
{% br_footer_rede_social href="#" icone="fa-linkedin-in" aria_label="LinkedIn" %}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment