Skip to content

Tera::render_str() takes a &mut self while it can work with a non-mutable reference. #943

@k1rowashere

Description

@k1rowashere

Context: I want to render a one off template, while using my custom filters, and macros.

TEMPLATES.render_str() is perfect for that, but it requires a &mut self, which is a problem because I have my Tera as a global static, and I don't want to wrap it in Arc:<Mutex<...>>.

It is mutable because of a call toself.build_inheritance_chains().

May I suggest :

  1. A non-mutable version where it disallows inheritance (using an assert! or return an error).
  2. Replace the existing method, but do the check without rebuilding (requires major refactoring/rewriting some logic to avoid code duplication).

p.s. I am willing to open a PR, but I am not familiar enough with codebase ( yet :) ).

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions