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

template:feeds: add extra block #2263

Merged
merged 5 commits into from
Aug 13, 2023
Merged

Conversation

heitorPB
Copy link
Contributor

@heitorPB heitorPB commented Jul 29, 2023

IMPORTANT: Please do not create a Pull Request adding a new feature without discussing it first.

The place to discuss new features is the forum: https://zola.discourse.group/
If you want to add a new feature, please open a thread there first in the feature requests section.

Sanity check:

  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Code changes

(Delete or ignore this section for documentation changes)

  • Are you doing the PR on the next branch?

If the change is a new feature or adding to/changing an existing one:

  • Have you created/updated the relevant documentation page(s)?

This PR adds an extra block on the feeds templates to allow users to customize the feeds with extra entries.

Forum post: https://zola.discourse.group/t/adding-tags-to-the-rss-atom-feeds/1820/4

I'm not happy with the names of the blocks, I think we can do better. What are your suggestions?

Comment on lines 51 to 53

{%- block atom_entry_extra %}
{% endblock atom_entry_extra -%}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand why, but these lines cause the tests to fail:

     Running tests/invalid.rs (/home/h/projects/zola/target/debug/deps/invalid-9ae7bc0e52bdd68b)

running 1 test
test errors_on_index_md_page_in_section ... FAILED

failures:

---- errors_on_index_md_page_in_section stdout ----
thread 'errors_on_index_md_page_in_section' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: Msg("Failed to parse '__zola_builtins/atom.xml'"), source: Some(Error { kind: Msg("  --> 52:9\n   |\n52 |         {% block atom_entry_extra %}\n   |         ^---\n   |\n   = unexpected tag; expected an `else` tag, an endfor tag (`{% endfor %}`), or some content"), source: None }) }', components/templates/src/lib.rs:28:6
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The message is:

$ echo -e "  --> 52:9\n   |\n52 |         {%- block atom_entry_extra %}\n   |         ^---\n   |\n   = unexpected tag; expected an `else` tag, an endfor tag (`{% endfor %}`), or some content"
  --> 52:9
   |
52 |         {%- block atom_entry_extra %}
   |         ^---
   |
   = unexpected tag; expected an `else` tag, an endfor tag (`{% endfor %}`), or some content

We can't add a block to a builtin template? I am not sure what I am missing here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to add <!-- Optional extra content --> inside the block to have some content, but I got the same error.

I also tried adding these lines to components/templates/src/lib.rs:19:

        ("__zola_builtins/atom.xml", "{% extends \"__zola_builtins/atom_base.xml\" %}{% block atom_entry_extra %}<>{% endblock atom_entry_extra %}"),
        ("__zola_builtins/rss.xml",  "{% extends \"__zola_builtins/rss_base.xml\" %}{% block rss_item_extra %}<>{% endblock rss_item_extra %}"),

And no success.

I'm not familiar with details on Tera, but does this mean we can't have an empty block in the built-in templates?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because the block is in a for loop, which is not allowed in Tera. Maybe the extend approach doesn't work then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's a bummer.

I reverted the commits and updated the docs on how to get the templates and modify. Maybe that's worth of a merge.

@heitorPB heitorPB marked this pull request as ready for review August 8, 2023 15:46
@Keats Keats merged commit 4474afa into getzola:next Aug 13, 2023
peterprototypes pushed a commit to peterprototypes/zola that referenced this pull request Sep 12, 2023
* template:feeds: add extra block

* add missing >

* Revert "add missing >"

This reverts commit 45c6b9c.

* Revert "template:feeds: add extra block"

This reverts commit 596f7f1.

* Update docs for feed templates
technimad pushed a commit to technimad/zola that referenced this pull request Sep 30, 2023
* template:feeds: add extra block

* add missing >

* Revert "add missing >"

This reverts commit 45c6b9c.

* Revert "template:feeds: add extra block"

This reverts commit 596f7f1.

* Update docs for feed templates
Keats pushed a commit that referenced this pull request Dec 18, 2023
* template:feeds: add extra block

* add missing >

* Revert "add missing >"

This reverts commit 45c6b9c.

* Revert "template:feeds: add extra block"

This reverts commit 596f7f1.

* Update docs for feed templates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants