-
Notifications
You must be signed in to change notification settings - Fork 10
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
Showing
6 changed files
with
72 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,4 @@ | ||
from django.utils.functional import keep_lazy_text | ||
|
||
from .__about__ import __version__ | ||
from .utils import get_icon_kwargs, get_icon_renderer | ||
|
||
__all__ = ["__version__", "icon"] | ||
|
||
|
||
@keep_lazy_text | ||
def icon(name, *args, **kwargs): | ||
""" | ||
Render an icon. | ||
**Parameters**: | ||
name | ||
The name of the icon to be rendered | ||
title | ||
The title attribute for the icon | ||
:default: None (no title attribute rendered) | ||
renderer | ||
The renderer to use for the icon | ||
:default: The default renderer as per ``settings.py``, or ultimately `FontAwesome4Renderer`. | ||
**Usage**:: | ||
icon(name) | ||
**Example**:: | ||
from .core import icon, render_icon | ||
|
||
icon('pencil') | ||
icon('trash', title='Delete') | ||
""" | ||
icon_kwargs = get_icon_kwargs(name, *args, **kwargs) | ||
renderer_class = get_icon_renderer(icon_kwargs.get("renderer", None)) | ||
renderer = renderer_class(**icon_kwargs) | ||
return renderer.render() | ||
__all__ = ["__version__", "icon", "render_icon"] |
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,51 @@ | ||
import warnings | ||
|
||
from django.utils.functional import keep_lazy_text | ||
|
||
from .utils import get_icon_kwargs, get_icon_renderer | ||
|
||
|
||
@keep_lazy_text | ||
def icon(name, *args, **kwargs): | ||
""" | ||
Render an icon. | ||
Deprecated because of frequent name collisions. | ||
""" | ||
warnings.warn("The `icon` function is deprecated, user `render_icon` instead.", DeprecationWarning) | ||
return render_icon(name, *args, **kwargs) | ||
|
||
|
||
@keep_lazy_text | ||
def render_icon(name, *args, **kwargs): | ||
""" | ||
Render an icon. | ||
**Parameters**: | ||
name | ||
The name of the icon to be rendered | ||
title | ||
The title attribute for the icon | ||
:default: None (no title attribute rendered) | ||
renderer | ||
The renderer to use for the icon | ||
:default: The default renderer as per ``settings.py``, or ultimately `FontAwesome4Renderer`. | ||
**Usage**:: | ||
icon(name) | ||
**Example**:: | ||
render_icon('pencil') | ||
render_icon('trash', title='Delete') | ||
""" | ||
icon_kwargs = get_icon_kwargs(name, *args, **kwargs) | ||
renderer_class = get_icon_renderer(icon_kwargs.get("renderer", None)) | ||
renderer = renderer_class(**icon_kwargs) | ||
return renderer.render() |
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