tailor icon indicating copy to clipboard operation
tailor copied to clipboard

Custom event during parsing template

Open AdelineCaro opened this issue 2 years ago • 2 comments

Hello,

Firstly I want to thank you for sharing this awesome project.

Then I really like to be able to add custom events in my custom fetchTemplate function, and catch them like other tailor event.

I explain the context : I got templates containing fragments. Those templates are made of "old scaring legacy code", and have there "own live" : they can add cookies or other stuff. I have a custom fetchTemplate with an axios method to get my template. On axios call, I can access all my template response header, including set-cookie, filled by my template. I want go transmit this cookie header to my rendered page. That's why I think about using events, as tailor does.

My issue is that I can't create an event emitter that I can pass to my fetchTemplate.

I see a solution : add tailor instance as argument to fetchTemplate function ? (it is in request-handler.js file)

Do you think it's possible ?

I can create a pull request if you want.

I hope I'm clear enough, Thanks for reading ;)

AdelineCaro avatar Jul 08 '22 13:07 AdelineCaro

I do a pull request for this issue : https://github.com/zalando/tailor/pull/348, with test and doc updates.

Can someone look at it ?

AdelineCaro avatar Jul 26 '22 09:07 AdelineCaro

Hey there !

Is this repo is still alive ?

AdelineCaro avatar Sep 13 '22 12:09 AdelineCaro