1

コメントツリーを生成したいと思います。

<ul>
   <li> First comment
      <ul> 
        <li> reply to first comment
        <li> another reply to first comment
      </ul>
   </li>
 </ul>

私はTree (Entity Comment)構造を持っています。私はhamletのすべての恩恵を受けたいと思います(#{commentContent comment}XSSから保護されます)。

Hamlet で再帰的な Html レンダリングを実現するにはどうすればよいですか?

4

1 に答える 1

4

普通の hamlet ではできないかもしれませんが、 を使用してアクセスできるヘルパー関数 commentTree を作成することはできます^{commentTree comments}。この関数は Hamlet を返し、それ自体[hamlet|<li>^{commentTree subcomment}|]を再帰と[hamlet|<u>#{commentContent comment}|]安全な補間に使用できます。

(この回答に触発されました。)

于 2012-08-28T10:35:47.103 に答える