Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditions in templates #170

Open
ilyachch opened this issue Nov 15, 2024 · 1 comment
Open

Conditions in templates #170

ilyachch opened this issue Nov 15, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@ilyachch
Copy link

I think, it would be great to have an option to use conditions in templates.

I think it's syntax should be like:

{%if <condition1>%}
...block to include if <condition1> is true
{%elif <condition2>%}
...block to include if <condition2> is true
{%else%}
...block to include if <condition1> and <condition2> both are false
{%endif%}

also it should support inversion:

{%if !<condition1>%}
...block to include if <condition1> is false
{%endif%}

For example, a common template could be like this:

# {{title}}

{%if highlights%}

{{highlights|template:"${text}"|callout:("INFO", "Important", true)}}

{%endif%}

{{content}}

## Links

- [{{title}}]({{url}})

Currently if there are no highlights, there will be empty callout.

But with conditions, callout will be only if there is any highlight

Also it can work with selectors:

{%if selector:.some_block%}
...show some things if .some_block element presents on the page
{%endif%}
@kepano
Copy link
Collaborator

kepano commented Nov 16, 2024

See roadmap

@kepano kepano added the enhancement New feature or request label Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants