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

Core: Inheritance in Pebble templates #3735

Closed
slandelle opened this issue May 17, 2019 · 0 comments
Closed

Core: Inheritance in Pebble templates #3735

slandelle opened this issue May 17, 2019 · 0 comments

Comments

@slandelle
Copy link
Member

From mailing list:

I'm using Pebble templates to generate the request bodies I'm using for my calls, now one of the main features of Pebble is that it supports inheritance but I can't get it to work. I have a parent template search-filter.peb

{
  "first": 0,
  "rows": 10,
  "filters": {
    {% block additionalFilter %} {% endblock %}
  }
}

and a child template

{% extends "search-filter.peb" %}

{% block additionalFilter %}
      "status": "PENDING"
{% endblock %}

and I import this into my call like this:

  val search: ChainBuilder = exec(http("Search")
    .post("/my-service/search")
    .body(PebbleFileBody("child-filter.peb")).asJson
    .headers(Config.requestHeaders)
  )
=========================
HTTP request:
POST my-service/asset-purchases/search
Connection: keep-alive
Accept: application/json
DNT: 1
Accept-Language: en-US
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
accept-encoding: gzip, deflate
host: ***
content-type: application/json
content-length: 13
stringBody=child-filter
=========================

do I need to do something else to get this inheritance to work? Or refer to the path in a different way? All templates are just located under the /main/resources folder.

@slandelle slandelle added this to the 3.2.0 milestone May 29, 2019
@slandelle slandelle self-assigned this May 29, 2019
slandelle added a commit that referenced this issue May 29, 2019
Motivation:

We always use a StringLoader to load templates, meaning that inheritance is not available.

Modifications:

* Modifify Resource implementations to keep track of classpath and filesystem resources.
* Have PebbleFileBody use the default Pebble Loader

Result:

Pebble templates inheritance is supported
@slandelle slandelle modified the milestones: 3.1.3, 3.2.0 Jun 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant