tera icon indicating copy to clipboard operation
tera copied to clipboard

Custom resolver

Open vincent-herlemont opened this issue 4 years ago • 3 comments

I have to create a custom resolver. This one has two sources: embedded (in the binary) and file (the local file system).

Example:

Embedded parent template:

{% block title %} parent title {% endblock title %}

Local child template:

{% extends "embedded://template" %}
{% block title %} child title {% endblock title %}

Currently, I use the method add_raw_template to add different templates, but following this way I have to create my own resolver.

There is another way to use the resolver used by the method Tera::new to add some custom behaviours without rewrite a resolver?

vincent-herlemont avatar Aug 09 '21 14:08 vincent-herlemont

No custom resolvers no. Do you need to differentiate the origin?

Keats avatar Aug 09 '21 15:08 Keats

Do you need to differentiate the origin?

Yes. Like that:

  • file://<template> for template in local file system.
  • embedded://<template> for template embedded in the binary.

vincent-herlemont avatar Aug 09 '21 16:08 vincent-herlemont

Yes but why not load all of them in one instance and just extend "template"? What I meant by Do you need to differentiate the origin? is can you have 2 templates with the same name and do you need to be able to refer to one or the other? Otherwise there is no plan on having custom resolvers, you can use globwalk and rename manually if you need.

Keats avatar Aug 09 '21 17:08 Keats