在django中实现羽毛图标的简单标记
django-feather的Python项目详细描述
django羽毛
在django中实现Feather Icons的简单标记({% icon "name" %}
)。
安装
使用pip
安装django-feather
,并将其放入INSTALLED_APPS
:
pip install django-feather
settings.py
:
INSTALLED_APPS=[# ...'django_feather',# ...]
用法
安装后,可以像使用任何其他标记一样使用标记:
{% load icon %} <p>Using a string {% icon "coffee" class="css-class" height="8" width="8" %}</p> <p>Using a variable {% icon self.icon class="css-class" height="8" width="8" %}</p>
标记icon
将简单地从feather项目中获取svg源代码,
应用其他属性并返回svg标记。
性能
django-feather
不会在每次呈现图标时读取.svg
文件。
相反,所有的图标在构建时都会写入到一个.py
文件中,就像javascript一样
图书馆。
但是,除了javascript库之外,图标是在服务器端呈现的。
这样可以避免在页面加载后调用feather.replace()
。
许可证
羽毛是根据MIT License授权的。
django-feather
在apache许可下获得许可,版本2.0:
Copyright 2019 Jonas Drotleff <j.drotleff@desk-lab.de>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.