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

How to generate output with a different extension? #70

Open
konstruktiv opened this issue May 8, 2018 · 2 comments
Open

How to generate output with a different extension? #70

konstruktiv opened this issue May 8, 2018 · 2 comments
Milestone

Comments

@konstruktiv
Copy link
Contributor

By default, statik generates HTML output. To get output with any other type of extension, we can make a change in view.py, e.g.: default_output_ext='.txt'

Is there a way to submit a parameter somewhere to set a project's output extension?

@konstruktiv konstruktiv changed the title How to generate output with a different extension How to generate output with a different extension? May 8, 2018
@konstruktiv
Copy link
Contributor Author

This can be done with a few changes starting on line 336 of views.py:

    if 'output-extension' in self.vars and self.vars['output-extension']:
        output_ext = self.vars['output-extension']
    else:
        output_ext = default_output_ext
    self.path = StatikViewPath.create(
        self.vars['path'],
        template_engine=template_engine,
        output_filename=default_output_filename,
        output_ext=output_ext,
        view_name=self.name
    )

Then you can add output-extension: .txt to the yml view file of the pages concerned.

@thanethomson Useful enough for a PR?

@jayvdb
Copy link
Collaborator

jayvdb commented Nov 10, 2018

What about determining the output filename from the template filename extensions.

i.e. how in #71

path: /google_image_sitemap.xml
template: google_image_sitemap.xml.jinja2
...

@thanethomson thanethomson added this to the v0.23.0 milestone Jan 13, 2019
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

3 participants