Skip to content

Instantly share code, notes, and snippets.

@sairion
Created October 29, 2014 08:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sairion/f637c77602b228fa3600 to your computer and use it in GitHub Desktop.
Save sairion/f637c77602b228fa3600 to your computer and use it in GitHub Desktop.
inline_svg.py
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
@sairion
Copy link
Author

sairion commented Oct 29, 2014

xlink 의 존재를 알고 폐기 ㅜㅜ
http://css-tricks.com/svg-use-external-source/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment