diff --git a/LICENSE b/LICENSE index 5e9f32f..7aa1d09 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2022 Paul Smith. All rights reserved. +Copyright (c) Paul Smith. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/main.go b/main.go index dd57367..37e42a2 100644 --- a/main.go +++ b/main.go @@ -1514,9 +1514,11 @@ func (g *pageCodeGen) genNodePartial(n node, p *partial) { g.bodyPrintf("printEscaped(%s, %s)\n", g.ioWriterVar, n.expr) } case *nodeFor: - g.bodyPrintf("for %s {\n", n.clause.code) - f(n.block) - g.bodyPrintf("}\n") + if state == stateInPartialScope { + g.bodyPrintf("for %s {\n", n.clause.code) + f(n.block) + g.bodyPrintf("}\n") + } return false case *nodeIf: g.bodyPrintf("if %s {\n", n.cond.expr) diff --git a/testdata/partial_for.out b/testdata/partial_for.out new file mode 100644 index 0000000..46b0f21 --- /dev/null +++ b/testdata/partial_for.out @@ -0,0 +1,11 @@ + + +
0
+1
+2
+ +^i
+} +^partial p { +