hugo

Fork of github.com/gohugoio/hugo with reverse pagination support

git clone git://git.shimmy1996.com/hugo.git

datatable-filtered.html (952B)

    1 {{ $package := (index .Params 0) }}
    2 {{ $listname := (index .Params 1) }}
    3 {{ $filter := split (index .Params 2) " " }}
    4 {{ $filter1 := index $filter 0 }}
    5 {{ $filter2 := index $filter 1 }}
    6 {{ $filter3 := index $filter 2 }}
    7 
    8 {{ $list := (index (index .Site.Data.docs $package) $listname) }}
    9 {{ $fields := after 3 .Params }}
   10 {{ $list := where $list $filter1 $filter2 $filter3 }}
   11 
   12 <table class="table table-bordered">
   13 	<tr>
   14 		{{ range $fields }}
   15 		<th>{{ . }}</th>
   16 		{{ end }}
   17 	</tr>
   18 	{{ range $list }}
   19 	<tr>
   20 		{{ range $k, $v := . }}
   21 		{{ $.Scratch.Set $k $v }}
   22 		{{ end }}
   23 		{{ range $k, $v := $fields }}
   24 			<td>
   25 				{{ $tdContent := $.Scratch.Get . }}
   26 				{{ if eq $k 3 }}
   27 					{{ printf "%v" $tdContent |
   28 							strings.ReplaceRE `\[` "<ol><li>" |
   29 							strings.ReplaceRE `\s` "</li><li>" |
   30 							strings.ReplaceRE `\]` "</li></ol>" |
   31 							safeHTML }}
   32 				{{ else }}
   33 					{{ $tdContent }}
   34 				{{ end}}
   35 			</td>
   36 		{{ end }}
   37 	</tr>
   38 	{{ end }}
   39 </table>