Skip to content

Commit

Permalink
减少模板渲染需要传递的参数个数
Browse files Browse the repository at this point in the history
  • Loading branch information
MingxingLAI committed Apr 13, 2017
1 parent 32a12ec commit 6780eec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 1 addition & 5 deletions headlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
def get_news(publication="zhihu"):
feed = feedparser.parse(RSS_FEED[publication])
first_content = feed['entries'][0]

entry = dict(title=first_content.get('title'),
published=first_content.get('published'),
summary=first_content.get('summary'))
return render_template('home.html', **entry)
return render_template('home.html', article=first_content)


if __name__ == '__main__':
Expand Down
6 changes: 3 additions & 3 deletions templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
</head>
<body>
<h1>Headlines</h1>
<b>{{title}}</b><br />
<i>{{published}}</i><br />
<p>{{summary}}</p>
<b>{{article.title}}</b><br />
<i>{{article.published}}</i><br />
<p>{{article.summary}}</p>
</body>
</html>

0 comments on commit 6780eec

Please sign in to comment.