-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use marksafe and jinja templates instead of webhelpers2
fixes #111
- Loading branch information
1 parent
3bb8f7a
commit 8f68e07
Showing
5 changed files
with
41 additions
and
28 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
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,16 @@ | ||
import flask | ||
from markupsafe import Markup | ||
|
||
|
||
def render_jinja(source, **kwargs): | ||
template = flask.current_app.jinja_env.from_string(source) | ||
return Markup(template.render(**kwargs)) | ||
|
||
|
||
def link_to(label, url, **kwargs): | ||
return render_jinja( | ||
'<a href="{{url}}" {{- attrs|html_attributes }}>{{label}}</a>', | ||
url=url, | ||
attrs=kwargs, | ||
label=label | ||
) |
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