Skip to content

Commit 7233238

Browse files
committed
Add exclude to the directory_contents templatetag. #43
1 parent a120653 commit 7233238

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

docs/source/common/templates.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,33 @@ If the request url is https://localhost:8000/ and there are these files:
125125
</ul>
126126
```
127127

128+
**Exclude a slug from being included**
129+
130+
If the request url is https://localhost:8000/ and there are these files:
131+
132+
- content/articles/article1.md
133+
- content/articles/article2.md
134+
135+
```markdown
136+
# Articles
137+
138+
{% directory_contents "articles" exclude="article1" as directory_contents %}
139+
140+
{% for content in directory_contents %}
141+
142+
- {{ content.slug }}
143+
144+
{% endfor %}
145+
```
146+
147+
```html
148+
<h1 id="articles">Articles</h1>
149+
150+
<ul>
151+
<li>article2</li>
152+
</ul>
153+
```
154+
128155
#### `include_md`
129156

130157
Similar to the [`include`](https://docs.djangoproject.com/en/stable/ref/templates/builtins/#include) template tag, but can be used to include a markdown file and have it render correctly into HTML. It can be used in markdown files or in HTML templates.

0 commit comments

Comments
 (0)