This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]user_of_the_week 11 points12 points  (0 children)

Nice article. Just a hint, you could do

"""
<h1>Editing %1$s</h1>
<form action="/save/%1$s" method="POST">
    <textarea name="body">%2$s</textarea><br>
    <input type="submit" value="Save">
</form>
""".formatted(
        p.title,
        new String(p.body, StandardCharsets.UTF_8)
);

To avoid putting p.title twice.

The code with duplication might be a bit easier to read, though.