I am writing a blog post template that has comments. The natural way of writing a template for streaming comments uses a recursive way to build Html. Something like that:
@showComment(comment: models.Comment) = { <div class="comment"> <div class="comment-metadata"> <span class="comment-author">by @comment.author,</span> <span class="comment-date"> @comment.postedAt.format("dd MMM yy") </span> </div> <div class="comment-content"> <div class="about">Detail: </div> @Html(comment.content.replace("\n", "<br>")) </div> <a href="@action(controllers.Application.replyComment(comment.id()))">Reply</a> @comments filter { c => c.parent_id == comment.id } map { c => @showComment(c) } </div> }
The problem is that using a recursive block gives an error:
An error occurred: the recursive showComment method requires a result type
If I try to put the return type in showComment, it calls this message:
An error occurred: not found: showComment value
Any workaround?
source share