zalando/tailor

Use templates sent along with the request.

Pixelatex opened this issue · 4 comments

Templates are compiled by an older service that we can't replace. To use fragments, we'd like to run tailor over the resulting html output before it gets sent back to the client.

So basically we'd send a call to the tailor node server that contains a stringified html.

However... it seems like tailor requires templates to be physical files in your own folders or on a server somewhere else... :/

I'd expect there to be a "template = string" option that we can pass to the request handler.

let tailor = new Tailor({
    templatesPath: __dirname + '/../templates', // in case you had any local templates
    fetchTemplate: (templatesPath, baseTemplateFn) => {
        // any logic you might have that gets returns a Promise fetching the template
    },
});

Did you solve this @Pixelatex? I'm in a similar position, using fetchTemplate to query the older service to get the HTML. However, it's not possible to pass cookies and headers from fetchTemplate to the response.

@stevoPerisic apologies that I never responded, the fetchTemplate does work indeed
@atkinchris I have no need for passing along cookies and headers like that, I think your implementation may need tweaking to use this