-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
91c9052
commit 8a83f24
Showing
9 changed files
with
90 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
from .tags import do_merge_attrs, do_slot, do_render_slot, do_partial | ||
from .tags import do_merge_attrs, do_slot, do_render_slot, do_partial, do_assets | ||
from .decorators import component_inline_tag, component_block_tag | ||
from .partials import render_partial_from_template | ||
from .partials import render_partial_from_template, PartialResponse | ||
|
||
__all__ = [ | ||
"do_merge_attrs", | ||
"do_slot", | ||
"do_render_slot", | ||
"do_assets", | ||
"component_inline_tag", | ||
"component_block_tag", | ||
"do_partial", | ||
"render_partial_from_template", | ||
"PartialResponse", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" | ||
Assets management for Django Component Kit. | ||
""" | ||
from typing import Iterable | ||
|
||
|
||
class AssetRegistry: | ||
"""Registry for assets""" | ||
|
||
def __init__(self): | ||
self.js = set() | ||
self.css = set() | ||
|
||
def add_js(self, js_list: Iterable[str] | None): | ||
"""Add JS files""" | ||
js_list = js_list or [] | ||
self.js.update([f'<script src="{js}" defer></script>' for js in js_list]) | ||
|
||
def add_css(self, css_list: Iterable[str] | None): | ||
"""Add CSS files""" | ||
css_list = css_list or [] | ||
self.css.update([f'<link crossorigin="anonymous" href="{css}" rel="stylesheet">' for css in css_list]) | ||
|
||
|
||
assets = AssetRegistry() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters