From a9465123443368cb7313468c38865e03ddb9d8fe Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 1 Mar 2013 07:21:11 +0100 Subject: [PATCH] Put HTML generation into its own method. --- .../rhynodge/triggers/NewComicTrigger.java | 26 ++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/pterodactylus/rhynodge/triggers/NewComicTrigger.java b/src/main/java/net/pterodactylus/rhynodge/triggers/NewComicTrigger.java index 45c290f..1b64c5b 100644 --- a/src/main/java/net/pterodactylus/rhynodge/triggers/NewComicTrigger.java +++ b/src/main/java/net/pterodactylus/rhynodge/triggers/NewComicTrigger.java @@ -121,16 +121,28 @@ public class NewComicTrigger implements Trigger { html.append(""); for (Comic newComic : newComics) { - html.append("

").append(StringEscapeUtils.escapeHtml4(newComic.title())).append("

\n"); - for (Strip strip : newComic) { - html.append("
\"").append(StringEscapeUtils.escapeHtml4(strip.comment()));
\n"); - } + generateComicHtml(html, newComic); } return html.append("").toString(); } + /** + * Generates the HTML for a single comic. + * + * @param html + * The string builder to append the HTML to + * @param comic + * The comic to render + */ + private void generateComicHtml(StringBuilder html, Comic comic) { + html.append("

").append(StringEscapeUtils.escapeHtml4(comic.title())).append("

\n"); + for (Strip strip : comic) { + html.append("
\"").append(StringEscapeUtils.escapeHtml4(strip.comment()));
\n"); + } + } + } -- 2.7.4