Created
October 29, 2014 08:10
-
-
Save sairion/f637c77602b228fa3600 to your computer and use it in GitHub Desktop.
inline_svg.py
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
from jinja2 import Markup | |
def include_raw(filename, wrapwith='div', classname='', endpoint='static'): | |
"""Include raw file content into Jinja2 template. Applicable for | |
document such as XML, SVG, PostScript. | |
Usage example: | |
{{ include_raw('images/icon.svg', classname='icon', wrapwith='span') }} | |
""" | |
with file(os.path.join(app.root_path, endpoint, filename), | |
'r') as file_content: | |
content = file_content.read() | |
return Markup('<{wrapwith} class="{classname}">' | |
'{content}' | |
'</{wrapwith}>'.format(wrapwith=wrapwith, | |
classname=classname, | |
content=content)) | |
app.jinja_env.globals['include_raw'] = include_raw |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
xlink 의 존재를 알고 폐기 ㅜㅜ
http://css-tricks.com/svg-use-external-source/