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

Side by Side Diff: templates/product-home.tmpl

Issue 29754555: Noissue - Use selectattr() filter to filter page metadata
Patch Set: Created April 17, 2018, 6:18 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « includes/product-topics-accordion.tmpl ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 {% extends "templates/minimal" %} 1 {% extends "templates/minimal" %}
2 2
3 {% set product = products[product_id] %} 3 {% set product = products[product_id] %}
4 {% set title_suffix = product.full_name + " Help Center" %} 4 {% set title_suffix = product.full_name + " Help Center" %}
5 5
6 {% block body %} 6 {% block body %}
7 <main id="main" class="container"> 7 <main id="main" class="container">
8 <header class="product-heading"> 8 <header class="product-heading">
9 <h1 class="has-pre-icon"> 9 <h1 class="has-pre-icon">
10 <span class="pre-icon" style="{{ get_inline_bg('logo-'+product_id) }}"></s pan> 10 <span class="pre-icon" style="{{ get_inline_bg('logo-'+product_id) }}"></s pan>
11 {{ product.full_name + " Help Center" | translate(product_id+"-help-home-t itle", "Page title") }} 11 {{ product.full_name + " Help Center" | translate(product_id+"-help-home-t itle", "Page title") }}
12 </h1> 12 </h1>
13 </header> 13 </header>
14 14
15 {% set popular_topics = get_pages_metadata({ "product_id": product_id, "templa te": "article", "popular": "true" }) %} 15 {% set product_topics = get_pages_metadata()|selectattr("product_id", "equalto ", product_id)
16 |selectattr("template", "equalto", "article")|list %}
17 {% set popular_topics = product_topics|selectattr("popular", "equalto", "true" )|list %}
16 {% if popular_topics %} 18 {% if popular_topics %}
17 <section class="card {{ product_id }}-card section"> 19 <section class="card {{ product_id }}-card section">
18 <h2 class="card-heading has-pre-icon"> 20 <h2 class="card-heading has-pre-icon">
19 <span class="pre-icon" style="{{ get_inline_bg('popular-icon') }}"></span> 21 <span class="pre-icon" style="{{ get_inline_bg('popular-icon') }}"></span>
20 {{ "Popular Topics" | translate("popular-topics-title", "Section title") } } 22 {{ "Popular Topics" | translate("popular-topics-title", "Section title") } }
21 </h2> 23 </h2>
22 24
23 <ul class="underlined-list row"> 25 <ul class="underlined-list row">
24 {% for article in popular_topics %} 26 {% for article in popular_topics %}
25 <li class="column one-half"> 27 <li class="column one-half">
26 <a href="{{ article["page"] }}"> 28 <a href="{{ article["page"] }}">
27 {{ article.title | translate( get_page_name( article["page"]) + "-titl e", "Article title") }} 29 {{ article.title | translate( get_page_name( article["page"]) + "-titl e", "Article title") }}
28 </a> 30 </a>
29 </li> 31 </li>
30 {% endfor %} 32 {% endfor %}
31 </ul> 33 </ul>
32 </section> 34 </section>
33 {% endif %} 35 {% endif %}
34 36
35 <div class="row"> 37 <div class="row">
36 {% for category in product.help_categories %} 38 {% for category in product.help_categories %}
37 {% set articles = get_pages_metadata({ "product_id": product_id, "template": "article", "category": category.name }) %} 39 {% set articles = product_topics|selectattr("category", "equalto", category. name)|list %}
38 {% if articles and category.name != 'Popular Topics' %} 40 {% if articles and category.name != 'Popular Topics' %}
39 <section class="section column one-half"> 41 <section class="section column one-half">
40 <h2 class="h4 has-pre-icon"> 42 <h2 class="h4 has-pre-icon">
41 <span class="pre-icon" style="{{ get_inline_bg(category.icon) }}"></span > 43 <span class="pre-icon" style="{{ get_inline_bg(category.icon) }}"></span >
42 {{ category.name | translate( category.slug + "-category-title", "Catego ry title") }} 44 {{ category.name | translate( category.slug + "-category-title", "Catego ry title") }}
43 </h2> 45 </h2>
44 46
45 <ul class="underlined-list"> 47 <ul class="underlined-list">
46 {% for article in articles %} 48 {% for article in articles %}
47 <li> 49 <li>
48 <a href="{{ article["page"] }}"> 50 <a href="{{ article["page"] }}">
49 {{ article.title | translate( get_page_name( article["page"]) + "-ti tle", "Article title") }} 51 {{ article.title | translate( get_page_name( article["page"]) + "-ti tle", "Article title") }}
50 </a> 52 </a>
51 </li> 53 </li>
52 {% endfor %} 54 {% endfor %}
53 </ul> 55 </ul>
54 </section> 56 </section>
55 {% endif %} 57 {% endif %}
56 {% endfor %} 58 {% endfor %}
57 </div> 59 </div>
58 60
59 </main> 61 </main>
60 {% endblock %} 62 {% endblock %}
61 63
62 {% block footer %} 64 {% block footer %}
63 <? include contact ?> 65 <? include contact ?>
64 {% endblock %} 66 {% endblock %}
OLDNEW
« no previous file with comments | « includes/product-topics-accordion.tmpl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld