1
0
Fork 0

Merging upstream version 0.56+dfsg.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-02 13:03:34 +02:00
parent 683f3a672a
commit aeb0367086
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
23 changed files with 131 additions and 20 deletions

View file

@ -1,3 +1,7 @@
"""
JinjaX
Copyright (c) Juan-Pablo Scaletti <juanpablo@jpscaletti.com>
"""
import pytest
import jinjax

View file

@ -1,3 +1,7 @@
"""
JinjaX
Copyright (c) Juan-Pablo Scaletti <juanpablo@jpscaletti.com>
"""
import pytest
import jinjax

View file

@ -1,3 +1,7 @@
"""
JinjaX
Copyright (c) Juan-Pablo Scaletti <juanpablo@jpscaletti.com>
"""
import pytest
from jinjax import Component, DuplicateDefDeclaration, InvalidArgument

View file

@ -1,3 +1,7 @@
"""
JinjaX
Copyright (c) Juan-Pablo Scaletti <juanpablo@jpscaletti.com>
"""
import pytest
from jinjax.html_attrs import HTMLAttrs

View file

@ -1,3 +1,7 @@
"""
JinjaX
Copyright (c) Juan-Pablo Scaletti <juanpablo@jpscaletti.com>
"""
import typing as t
from pathlib import Path

View file

@ -1,3 +1,7 @@
"""
JinjaX
Copyright (c) Juan-Pablo Scaletti <juanpablo@jpscaletti.com>
"""
import jinja2
import pytest
from markupsafe import Markup

View file

@ -1,3 +1,7 @@
"""
JinjaX
Copyright (c) Juan-Pablo Scaletti <juanpablo@jpscaletti.com>
"""
import time
from textwrap import dedent
@ -243,6 +247,24 @@ def test_subfolder(catalog, folder, autoescape, undefined):
assert html == Markup('<div class="tab">Meh</div>')
@pytest.mark.parametrize("undefined", [jinja2.Undefined, jinja2.StrictUndefined])
@pytest.mark.parametrize("autoescape", [True, False])
def test_subfolder_index_file(catalog, folder, autoescape, undefined):
"""Components named "index.jinja" in subfolders can be called
using the subfolder names.
"""
catalog.jinja_env.autoescape = autoescape
catalog.jinja_env.undefined = undefined
sub = folder / "tab"
sub.mkdir()
(sub / "index.jinja").write_text("Hello")
(sub / "panel.jinja").write_text("World")
assert catalog.render("Tab") == Markup("Hello")
assert catalog.render("Tab.Panel") == Markup("World")
@pytest.mark.parametrize("undefined", [jinja2.Undefined, jinja2.StrictUndefined])
@pytest.mark.parametrize("autoescape", [True, False])
def test_default_attr(catalog, folder, autoescape, undefined):

View file

@ -1,3 +1,7 @@
"""
JinjaX
Copyright (c) Juan-Pablo Scaletti <juanpablo@jpscaletti.com>
"""
from pathlib import Path
import jinja2
@ -57,14 +61,14 @@ def test_render_assets(catalog, folder, autoescape, undefined):
assert (
"""
<html>
<link rel="stylesheet" href="https://somewhere.com/style.css">
<link rel="stylesheet" href="/static/components/card.css">
<link rel="stylesheet" href="/static/components/greeting.css">
<link rel="stylesheet" href="http://example.com/super.css">
<script type="module" src="https://somewhere.com/blabla.js"></script>
<script type="module" src="/static/components/shared.js"></script>
<link rel="stylesheet" href="https://somewhere.com/style.css">
<script type="module" src="/static/components/card.js"></script>
<script type="module" src="/static/components/greeting.js"></script>
<script type="module" src="/static/components/shared.js"></script>
<script type="module" src="https://somewhere.com/blabla.js"></script>
<section class="card">
<div class="greeting [&_a]:flex">Hello</div>
<button type="button">Close</button>
@ -195,8 +199,8 @@ def test_auto_load_assets_with_same_name(catalog, folder, autoescape, undefined)
<link rel="stylesheet" href="/static/components/Page.css">
<link rel="stylesheet" href="/static/components/common/Form.css">
<script type="module" src="/static/components/Page.js"></script>
<script type="module" src="/static/components/shared.js"></script>
<script type="module" src="/static/components/common/Form.js"></script>
<script type="module" src="/static/components/shared.js"></script>
<form></form>
""".strip()

View file

@ -1,3 +1,7 @@
"""
JinjaX
Copyright (c) Juan-Pablo Scaletti <juanpablo@jpscaletti.com>
"""
from threading import Thread
from markupsafe import Markup