_webr_value_{{block_id}} = {
  const { highlightR, b64Decode } = window._exercise_ojs_runtime;
  const scriptContent = document.querySelector(`script[type=\"webr-{{block_id}}-contents\"]`).textContent;
  const block = JSON.parse(b64Decode(scriptContent));

  // Default evaluation configuration
  const options = Object.assign({
    id: "webr-{{block_id}}-contents",
    echo: true,
    output: true
  }, block.attr);

  // Evaluate the provided R code
  const result = webROjs.process({code: block.code, options}, {{block_input}});

  // Early yield while we wait for the first evaluation and render
  if (options.output && !("{{block_id}}" in webROjs.renderedOjs)) {
    const container = document.createElement("div");
    const spinner = document.createElement("div");

    if (options.echo) {
      // Show output as highlighted source
      const preElem = document.createElement("pre");
      container.className = "sourceCode";
      preElem.className = "sourceCode r";
      preElem.appendChild(highlightR(block.code));
      spinner.className = "spinner-grow spinner-grow-sm m-2 position-absolute top-0 end-0";
      preElem.appendChild(spinner);
      container.appendChild(preElem);
    } else {
      spinner.className = "spinner-border spinner-border-sm";
      container.appendChild(spinner);
    }

    yield container;
  }

  webROjs.renderedOjs["{{block_id}}"] = true;
  yield await result;
}
