Skip to content

Commit

Permalink
Rework mechanism to allow single-line comments that is compatible with
Browse files Browse the repository at this point in the history
diet live mode. Fix issue with 'return;'
  • Loading branch information
schveiguy committed Oct 25, 2019
1 parent f4908f3 commit 9708046
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions source/diet/html.d
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,10 @@ private string getCodeMixin(ref CTX ctx, in ref Node node, bool in_pre) @safe
bool have_contents = node.contents.length > 1;
foreach (i, c; node.contents) {
if (i == 0 && c.kind == NodeContent.Kind.text) {
ret ~= ctx.statement(node.loc, "%s", c.value);
if(have_contents)
ret ~= ctx.statement(node.loc, "{");
ret ~= ctx.statement(node.loc, "%s\n{", c.value);
else
ret ~= ctx.statement(node.loc, "%s", c.value);
} else {
assert(c.kind == NodeContent.Kind.node);
ret ~= ctx.getHTMLMixin(c.node, in_pre);
Expand Down Expand Up @@ -713,7 +714,7 @@ private struct CTX {
// we must suppress html output.
auto nextLine = (fmt~"\n").format(args);
auto firstNonSpace = nextLine.splitter;
immutable isReturn = !firstNonSpace.empty && firstNonSpace.front == "return";
immutable isReturn = !firstNonSpace.empty && (firstNonSpace.front == "return" || firstNonSpace.front == "return;");
immutable isElse = !firstNonSpace.empty && firstNonSpace.front == "else";
with(OutputMode) final switch(mode)
{
Expand Down

0 comments on commit 9708046

Please sign in to comment.