use v6.e.PREVIEW; unit module Render::Util; use DB::Post; use HTML::Functional; sub show-html($html) is export { my $out = "$html"; # Work around HTML::Functional automatically putting newlines between tags $out ~~ s:g/'' \v+ ''/<\/i>/; $out ~~ s:g/\v+ ''/<\/a>/; $out ~~ s:g/',' \v+ ' Str:D) is export { my @slugs = $post.all-slugs; if @slugs { "/posts/by-slug/{@slugs[*-1]}.html" } else { "/posts/by-id/$id.html" } } sub icon($icon) is export { i(:class("bx bx-$icon")) } sub mins-to-string($mins) is export { if $mins < 60 { $mins.Str ~ "m" } else { my $h = $mins div 60; my $m = $mins mod 60; $h.Str ~ "h" ~ $m.Str ~ "m" } } sub intersperse (\element, +list) is export { gather for list { FIRST .take, next; take slip element, $_; } }