そのような組み込みのものはないと思います。幸いなことに、Hamlet ではヘルパー関数を簡単に使用できます。たとえば、アイテムがプレーンな文字列の場合、 を使用Data.List.intercalate
してそれらの間にカンマを追加できます。
The values in the list are
#{intercalate ", " list}
and that is it.
もっと手の込んだことをしたい場合は、Hamlet の値を操作する関数を作成できます。たとえば、リスト内の Hamlet 値の間にカンマと「and」を追加する関数を次に示します。
commaify [x] = x
commaify [x, y] = [hamlet|^{x} and ^{y}|]
commaify (x:xs) = [hamlet|^{x}, ^{commaify xs}|]
これは^{...}
構文を使用して、1 つの Hamlet 値を別の Hamlet 値に挿入します。これを使用して、下線付きの単語のコンマ区切りリストを作成できます。
The values in the list are
^{commaify (map underline list)}
and that is it.
ここにunderline
あるのは、プレーン テキストよりも興味深いものを生成するための小さなヘルパー関数です。
underline word = [hamlet|<u>#{word}|]
レンダリングすると、次の結果が得られます。
The values in the list are <u>foo</u>, <u>bar</u> and <u>baz</u> and that is it.