Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: filters/find.py

Issue 5994668214976512: Issue 662 - Job links shouldn't use anchors (Closed)
Patch Set: Created March 23, 2015, 1:04 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | includes/jobs/footer.tmpl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: filters/find.py
===================================================================
new file mode 100644
--- /dev/null
+++ b/filters/find.py
@@ -0,0 +1,8 @@
+from jinja2 import environmentfilter
+
+@environmentfilter
+def find(environment, sequence, value, attribute=None):
+ for item in sequence:
+ if (item if attribute is None else environment.getitem(item, attribute)) == value:
+ return item
+ return None
« no previous file with comments | « no previous file | includes/jobs/footer.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld