[Django] #36353: Add `content` to `Script` media asset

2 views
Skip to first unread message

Django

unread,
Apr 25, 2025, 5:18:01 PM4/25/25
to django-...@googlegroups.com
#36353: Add `content` to `Script` media asset
-------------------------------------+-------------------------------------
Reporter: Johannes Maron | Type:
| Cleanup/optimization
Status: new | Component: Forms
Version: 5.2 | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
This is a follow-up to #35886

I noticed that the `Script` does support any attribute, but not a content
or innerHTML.

Currently:

{{{
element_template = '<script src="{path}"{attributes}></script>'
}}}

Better:

{{{
element_template = '<script src="{path}"{attributes}>{content}</script>'
}}}

You might want to just drop a `import "#myPackage"` inside the script tag,
to lead a file from your importmap.

This would look something like:


{{{
Script(type="module", content="import 'myPackage'")
}}}


I am not sure, if this is a bug, feature request or cleanup, someone
should review the ticket type.
--
Ticket URL: <https://code.djangoproject.com/ticket/36353>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 25, 2025, 5:19:36 PM4/25/25
to django-...@googlegroups.com
#36353: Add `content` to `Script` media asset
--------------------------------+--------------------------------------
Reporter: Johannes Maron | Owner: (none)
Type: New feature | Status: new
Component: Forms | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Changes (by Johannes Maron):

* type: Cleanup/optimization => New feature


Old description:

> This is a follow-up to #35886
>
> I noticed that the `Script` does support any attribute, but not a content
> or innerHTML.
>
> Currently:
>
> {{{
> element_template = '<script src="{path}"{attributes}></script>'
> }}}
>
> Better:
>
> {{{
> element_template = '<script src="{path}"{attributes}>{content}</script>'
> }}}
>
> You might want to just drop a `import "#myPackage"` inside the script
> tag, to lead a file from your importmap.
>
> This would look something like:
>

> {{{
> Script(type="module", content="import 'myPackage'")
> }}}
>

> I am not sure, if this is a bug, feature request or cleanup, someone
> should review the ticket type.

New description:

This is a follow-up to #35886

I noticed that the `Script` does support any attribute, but not a content
or innerHTML.

Currently:

{{{
element_template = '<script src="{path}"{attributes}></script>'
}}}

Better:

{{{
element_template = '<script{attributes}>{content}</script>'
}}}

You might want to just drop a `import "#myPackage"` inside the script tag,
to lead a file from your importmap.

This would look something like:


{{{
Script(type="module", content="import 'myPackage'")
}}}

--
--
Ticket URL: <https://code.djangoproject.com/ticket/36353#comment:1>

Django

unread,
Apr 25, 2025, 5:27:01 PM4/25/25
to django-...@googlegroups.com
#36353: Add `content` to `Script` media asset
--------------------------------+--------------------------------------
Reporter: Johannes Maron | Owner: (none)
Type: New feature | Status: new
Component: Forms | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Description changed by Johannes Maron:

Old description:

> This is a follow-up to #35886
>
> I noticed that the `Script` does support any attribute, but not a content
> or innerHTML.
>
> Currently:
>
> {{{
> element_template = '<script src="{path}"{attributes}></script>'
> }}}
>
> Better:
>
> {{{
> element_template = '<script{attributes}>{content}</script>'
> }}}
>
> You might want to just drop a `import "#myPackage"` inside the script
> tag, to lead a file from your importmap.
>
> This would look something like:
>

> {{{
> Script(type="module", content="import 'myPackage'")
> }}}

New description:

This is a follow-up to #35886

I noticed that the `Script` does support any attribute, but not a content
or innerHTML.

Currently:

{{{
element_template = '<script src="{path}"{attributes}></script>'
}}}

Better:

{{{
element_template = '<script{attributes}>{content}</script>'
}}}

You might want to just drop a `import "#myPackage"` inside the script tag,
to lead a file from your importmap.

This would look something like:


{{{
Script(type="module", content="import 'myPackage'")
}}}


This is going to complicate the path-based sorting I implemented back in
the day. But I believe the `path` can be swapped for `content` without
much trouble.

--
--
Ticket URL: <https://code.djangoproject.com/ticket/36353#comment:2>

Django

unread,
Apr 26, 2025, 7:03:27 AM4/26/25
to django-...@googlegroups.com
#36353: Add `content` to `Script` media asset
--------------------------------+--------------------------------------
Reporter: Johannes Maron | Owner: (none)
Type: New feature | Status: closed
Component: Forms | Version: 5.2
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Changes (by Sarah Boyce):

* resolution: => wontfix
* status: new => closed

Comment:

Thank you for the ticket
Can you first post this on the forum and confirm from a few others that
this is wanted (perhaps some of the folks from the original discussion
might have some opinions: https://forum.djangoproject.com/t/rejuvenating-
vs-deprecating-form-media/21285)?

If we have a few folks agreeing we can accept the ticket
--
Ticket URL: <https://code.djangoproject.com/ticket/36353#comment:3>
Reply all
Reply to author
Forward
0 new messages