Skip to content

Minimize repetition in the variables passed to render #51

@davemfish

Description

@davemfish

All model templates should be rendered with these variables, in addition to other model-specific variables:

We can try to minimize the need to define all of these in every reporter.

    with open(target_html_filepath, 'w', encoding='utf-8') as target_file:
        target_file.write(TEMPLATE.render(
            report_script=__file__,
            timestamp=time.strftime('%Y-%m-%d %H:%M'),
            model_id=model_spec.model_id,
            model_name=model_name,
            model_description=model_description,
            userguide_page=model_spec.userguide,
            args_dict=args_dict,
            model_spec_outputs=model_spec.outputs,
            ...
        ))
  • Perhaps we can define a wrapper/decorator that deals with defining the report_script and timestamp.
  • page_title can probably be removed entirely and constructed within base.html.
  • We could consider passing in the entire model_spec instead of various attributes, but I'm not sure if that's a good idea. It offloads the attribute access to the templates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions