openresty/demo/Blog/template/elem/comments.tt

30 lines
1.2 KiB
Plaintext

[%- FOREACH comment IN comments -%]
<a name="post-[% comment.post %]:comment-[% comment.id %]" id="post-[% comment.post %]:comment-[% comment.id %]"></a>
<div class="comment" id="comment-95523406">
<div class="comment-content">
[%- IF comment.body %]
[%- comment.body.replace('&', '&amp;')
.replace('<', '&lt;')
.replace('>', '&gt;')
.replace('\n', '<br/>')
.replace(' ', '&nbsp; ')
.replace('(http://(?:\%[A-Fa-f0-9]{2}|[-A-Za-z./0-9~_])+)', '<a href="$1">$1</a>') %]
[%- END %]
</div>
<p class="comment-footer">
Posted by:
[% IF comment.url %]
[%- url = comment.url %]
[% IF NOT url.match('^\\w+://');
url = 'http://' _ url;
END -%]
<a href="[% url | html %]">[% comment.sender | html %]</a>
[% ELSE %]
[% comment.sender | html %] |
[% END %]
[% comment.created | html %]
</p>
</div>
[%- END %]