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

Question about URL generators #123

Closed
ghost opened this issue Dec 22, 2021 · 1 comment
Closed

Question about URL generators #123

ghost opened this issue Dec 22, 2021 · 1 comment

Comments

@ghost
Copy link

ghost commented Dec 22, 2021

So, I am making a blog and I am trying to freeze it with Frozen-Flask. I have the following URL generator in my code:

@app.route('/blog/<path:path>.html')
def page(path):
    page = pages.get_or_404(path)
    return render_template('page.html', page=page)

How can I make Frozen-Flask register the URL generator?

@TomHall2020
Copy link

If you have used that url endpoint in other pages that are frozen, it should automatically follow those urls and freeze them.

Else if you want to force it, you can use @freezer.register_generator in a few different ways (but bear in mind users would then have to know to type the url directly into the browser to access them as you're not linking to these pages from anywhere). Here's one implementation

@freezer.register_generator
def blog_pages_generator():
   for page_object in pages:
        yield url_for(page, page=page_object)

See url-generators in the documentation

@liZe liZe closed this as completed Nov 12, 2023
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