function createFromTemplate(template, tileGrid) {
  return (
    /**
     * @param {import("./tilecoord.js").TileCoord} tileCoord Tile Coordinate.
     * @param {number} pixelRatio Pixel ratio.
     * @param {import("./proj/Projection.js").default} projection Projection.
     * @return {string|undefined} Tile URL.
     */
    function (tileCoord, pixelRatio, projection) {
      if (!tileCoord) {
        return undefined;
      }
      let maxY;
      const z = tileCoord[0];
      if (tileGrid) {
        // The `{-y}` placeholder only works for sources that have a tile grid at construction
        const range = tileGrid.getFullTileRange(z);
        if (range) {
          maxY = range.getHeight() - 1;
        }
      }
      return renderXYZTemplate(template, z, tileCoord[1], tileCoord[2], maxY);
    }
  );
}
@param {string} template Template.
@param {import("./tilegrid/TileGrid.js").default|null} tileGrid Tile grid.
@return {import("./Tile.js").UrlFunction} Tile URL function.