Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

N247S
Copy link

@N247S N247S commented Jan 3, 2023

This is a possible easy fix for the issue I reported yesterday.

I am not sure if the typescript declarations gets updated automatically, or if that takes additional actions,
If more things are required to push this, feel free to ask.

This change allows for the ClientFunction and AsyncClientFunction's third argument (includer) to be both a normal and an async function (or a normal function returning a Promise instance). In fact everything inside a raw-output and escaped-output tag can be. Example:

function customIncluder(options, path, data)
{
  return fetch(path)
    .then((r) => r.text())
    .then((t) => {
      ejs.compile(t, options)(data, null, (ipath, idata) => customIncluder(options, ipath, idata));
    })
}

let data;
let options = {client: true, async: true};
ejs.compile("<%- include("test.ejs") _%>", options)(data, null, (ipath, idata) => customIncluder(options, ipath, idata));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant