observablehq / stdlib

The Observable standard library.
https://observablehq.com/@observablehq/standard-library
ISC License
967 stars 83 forks source link

Add dot template literal. #7

Closed mbostock closed 6 years ago

mbostock commented 6 years ago

Since the Viz.js dependency is lazily loaded this would be a very small addition to the stdlib…

dot = {
  const Viz = await require("viz.js@1.8.0/viz-lite.js").catch(() => window.Viz);
  return function(strings) {
    let string = strings[0] + "", i = 0, n = arguments.length;
    while (++i < n) string += arguments[i] + "" + strings[i];
    const fragment = html([Viz(string)]);
    return fragment.removeChild(fragment.firstElementChild);
  };
}

https://beta.observablehq.com/@mbostock/graphviz

mbostock commented 6 years ago

Punting on this for now.