Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3c25e47

Browse files
committed
added jinja quick loa
1 parent0fb024c commit3c25e47

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

‎15_check_my_environment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ def get_config_file():
4242
print"Config file: {}".format(CONFIGFILE)
4343
ifnotos.path.exists(CONFIGFILE):
4444
sys.exit("Configuration error! Config file does not exist")
45-
print"Congig ok ...."
45+
print"Config ok ...."

‎16_jinja_quick_load.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
Render a quick Jinja2 template.
3+
Thanks Danny - http://pydanny.com/jinja2-quick-load-function.html
4+
5+
Example:
6+
7+
>>> from jinja_quick_load import render_from_template
8+
>>> data = {
9+
... "date": "June 12, 2014",
10+
... "items": ["oranges", "bananas", "steak", "milk"]
11+
... }
12+
>>> render_from_template(".", "shopping_list.html", **data)
13+
14+
"""
15+
16+
17+
fromjinja2importFileSystemLoader,Environment
18+
19+
20+
defrender_from_template(directory,template_name,**kwargs):
21+
loader=FileSystemLoader(directory)
22+
env=Environment(loader=loader)
23+
template=env.get_template(template_name)
24+
returntemplate.render(**kwargs)

‎readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
1.**13_random_name_generator.py**: random name generator
1616
1.**14_html_to_markdown.sh**: Convert all html files in a single directory to markdown
1717
1.**15_check_my_environment.py**: Pass in a config file based on your environment.
18+
1.**16_jinja_quick_load.py**: Render a quick Jinja2 template

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp