Commit b80086a9 authored by Eduardo Silva's avatar Eduardo Silva
Browse files

testando com automatizacao #9

parent 83097ddf
default_app_config = "dsgov.apps.DsgovConfig"
\ No newline at end of file
from django.apps import AppConfig from django.apps import AppConfig
from django.conf import settings
class DsgovConfig(AppConfig):
name = "dsgov"
verbose_name = "Design System Gov.br (Django)"
class DSGovConfig(AppConfig): def ready(self):
"""
name = 'dsgov' Registra automaticamente o context processor dsgov_init,
se ainda não estiver presente.
"""
try:
templates = settings.TEMPLATES[0]["OPTIONS"]
cps = templates.get("context_processors", [])
cp = "dsgov.context_processors.dsgov_init"
if cp not in cps:
cps.append(cp)
except Exception:
# Evita travar o setup se o settings estiver incompleto
pass
\ No newline at end of file
from django.template.loader import render_to_string
def dsgov_init(request):
"""
Injeta automaticamente o HTML de inicialização do DSGov em todos os templates.
"""
try:
html = render_to_string("dsgov/includes/init.html")
except Exception:
html = ""
return {"DSGOV_INIT": html}
\ No newline at end of file
...@@ -11,17 +11,16 @@ ...@@ -11,17 +11,16 @@
{% block title %} {% block title %}
{% endblock %} {% endblock %}
</title> </title>
<!-- Link para o fontawesome -->
<!-- FontAwesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<!-- Importando o CSS do govbr-ds -->
{% br_stylesheets %}
</head>
<body>
{% block content %}
{% endblock %}
<!-- Importando o JS do govbr-ds --> <!-- Inicialização DSGov -->
{% br_scripts %} {% br_init %}
</body> </head>
<body>
{% block content %}
{% endblock %}
</body>
</html> </html>
\ No newline at end of file
{% load br_components %}
{% load static %}
<!-- Importando o CSS do govbr-ds -->
{% br_stylesheets %}
<!-- Importando o JS do govbr-ds -->
{% br_scripts %}
\ No newline at end of file
...@@ -36,6 +36,10 @@ def br_scripts(): ...@@ -36,6 +36,10 @@ def br_scripts():
static('dsgov/dist/js/bundle.js') static('dsgov/dist/js/bundle.js')
) )
@register.inclusion_tag("dsgov/includes/init.html", takes_context=True)
def br_init(context):
"""Inclui automaticamente CSS e JS do DSGov."""
return {}
@register.simple_tag @register.simple_tag
def br_button(text='', button_type='', style='', extra_classes='', icon_class=''): def br_button(text='', button_type='', style='', extra_classes='', icon_class=''):
......
{% extends "dsgov/base.html" %} {% extends "dsgov/base.html" %}
{% load br_components %}
{% load static %}
{% block title %} {% block title %}
Componentes Django-DsGOV Componentes Django-DsGOV
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment