Skip to content

Commit e936297

Browse files
author
Sam Pullara
committed
fix for the unexecute issue with partials that are not well bracketed
1 parent 00ffc96 commit e936297

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

builder/src/main/java/com/sampullara/mustache/BuilderCodeFactory.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,17 @@ public int getLine() {
330330

331331
@Override
332332
public Scope unexecute(Scope current, String text, AtomicInteger position, Code[] next) throws MustacheException {
333-
String partialText = unexecuteValueCode(m, current, text, position, next, false);
334-
AtomicInteger partialPosition = new AtomicInteger(0);
335-
Scope unexecuted = m.partial(variable).unexecute(partialText, partialPosition);
336-
if (unexecuted == null) return null;
337-
put(current, variable, unexecuted);
333+
Mustache partial = m.partial(variable);
334+
Code[] compiled = partial.getCompiled();
335+
Scope unexecuted = new Scope();
336+
for (int i = 0; i < compiled.length && unexecuted != null; i++) {
337+
if (compiled[i] instanceof EOFCode) break;
338+
Code[] truncate = truncate(compiled, i + 1, new Code[0]);
339+
unexecuted = compiled[i].unexecute(unexecuted, text, position, truncate);
340+
}
341+
if (unexecuted != null) {
342+
put(current, variable, unexecuted);
343+
}
338344
return current;
339345
}
340346

src/test/resources/ibis2/content.html.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
</tr>
4040
<tr>
4141
<td style="font-size: 11px; line-height: 16px; color: #aaa; padding: 25px 40px;">
42-
{{_i}}If you'd rather not receive Twitter product or service updates, you can <a href="{{UNSUBSCRIBE}}" style="color: #6d90a9; text-decoration: none;" class="unsubscribe-link">unsubscribe</a> immediately. Please do not reply to this message; it was sent from an unmonitored email address. This message is a service email related to your use of Twitter. For general inquiries or to request support with your Twitter account, please visit us at <a href="http://support.twitter.com/" style="color: #6d90a9; text-decoration: none;">Twitter Support</a>. If you received this message in error and did not sign up for a Twitter account, click <a href="{{NOTMYACCOUNT}}" style='color: #6d90a9; text-decoration: none;'>not my account</a>.{{/i}}
42+
If you'd rather not receive Twitter product or service updates, you can <a href="{{UNSUBSCRIBE}}" style="color: #6d90a9; text-decoration: none;" class="unsubscribe-link">unsubscribe</a> immediately. Please do not reply to this message; it was sent from an unmonitored email address. This message is a service email related to your use of Twitter. For general inquiries or to request support with your Twitter account, please visit us at <a href="http://support.twitter.com/" style="color: #6d90a9; text-decoration: none;">Twitter Support</a>. If you received this message in error and did not sign up for a Twitter account, click <a href="{{NOTMYACCOUNT}}" style='color: #6d90a9; text-decoration: none;'>not my account</a>.
4343
</td>
4444
</tr>
4545
</table>

0 commit comments

Comments
 (0)