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

Variable not recognized inside base template #12

Open
markokocic opened this issue Mar 17, 2021 · 1 comment
Open

Variable not recognized inside base template #12

markokocic opened this issue Mar 17, 2021 · 1 comment

Comments

@markokocic
Copy link
Collaborator

Not sure if this is weblorg or templatel issue, feel free to close and move to weblorg if this is not the right place.

I have base.html template and home.html template that extends base.

The route is defined like this:

(weblorg-route
 ;; route for rendering index page of the blog
 :site blog
 :name "home"
 :input-pattern "posts/*.org"
 :input-aggregate #'weblorg-input-aggregate-all-desc
 :template "home.html"
 :output "output/index.html"
 :url "/")

home.html just lists posts and their descriptions in the main area.

Inside a base.html I tried to define a sidebar that will contain just links to the posts, by referencing the same post variable, like this:

          {% for post in posts %}
            <li><a href="{{ post.url }}">{{ post.title }}</a></li>
          {% endfor %}

When generating blog, I get the following error:
Template Error: base.html: Variable `posts' not declared

Is there a way in templatel and weblorg to achieve something like this? How can the variable be visible inside base template? Or it needs to be defined globally inside a weblorg-site?

One workaround could be to define an empty sidebar block in base.html, and to override that block inside every template that extends base, but that would be a repetition that I'd like to avoid if possible.

Or maybe wait until include is implemented, but then again, including would still need its route to set variables before including it as a html output.

@clarete
Copy link
Collaborator

clarete commented Apr 10, 2021

Sorry, haven't had time to look into this, but I think you're right that it'd be a templatel issue. Thank you for taking the time to file the issue 🙇🏾

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

No branches or pull requests

2 participants