const INDENT_REGEXP = /(?:\n)[ \t]+/g;

function changeIndent(str, diff) {
  return str.replace(INDENT_REGEXP, matched => "\n" + " ".repeat(matched.length + diff));
}

function getIndents(strings) {
  return strings
    .map(s => s.match(INDENT_REGEXP) || [])
    .reduce((a, b) => a.concat(b), [])
    .map(s => s.length);
}

function fixIndents(strings, indent) {
  const indents = getIndents(strings);
  const origIndent = indents.length > 0 ? Math.min(...indents) : 0;
  return strings.map(s => changeIndent(s, indent - origIndent));
}

// TODO: source map support

export default
function render(indentLevel) {
  const indent = indentLevel * 2;
  return function (strings, ...values) {
    const indentedStrings = fixIndents(strings, indent);

    let ret = "";

    for (let i = 0; i < strings.length; ++i) {
      ret += indentedStrings[i];
      if (i < values.length) {
        ret += String(values[i]);
      }
    }
    return ret;
  }
}

@@ -33,16 +33,166 @@
 t%5D+/g;%0A%0A
+function trimLast(strings) %7B%0A  return strings.map((s, i) =%3E %7B%0A    if (i === strings.length - 1) %7B%0A      return s.trim();%0A    %7D%0A    return s;%0A  %7D);%0A%7D%0A%0A
 function
@@ -865,39 +865,49 @@
 gs = fixIndents(
+trimLast(
 strings
+)
 , indent);%0A%0A    

Add trimLast