Skip to content

Commit

Permalink
Merge pull request #61 from charlesjlee/master
Browse files Browse the repository at this point in the history
New shortcode "pure_table" to create tables
  • Loading branch information
yoshiharuyamashita committed Dec 19, 2017
2 parents 2022217 + d4aa502 commit a775981
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Expand Up @@ -203,6 +203,19 @@ paginate = 10


## Shortcodes ## Shortcodes


### pure_table
```
{{< pure_table
"columnName1|columnName2|...|columnName99"
"dataValue1|dataValue2|...|dataValue99"
"dataValue1|dataValue2|...|dataValue99"
"dataValue1|dataValue2|...|dataValue99"
"... and so on"
>}}
```

where each positional parameter is separated by the vertical bar (i.e., |). The resulting `<table>` is set to have `class="pure-table pure-table-striped"`.

### fluid_imgs ### fluid_imgs


``` ```
Expand Down
20 changes: 20 additions & 0 deletions layouts/shortcodes/pure_table.html
@@ -0,0 +1,20 @@
{{ $fields := (index .Params 0) }}
{{ $data := after 1 .Params }}

<table class="pure-table pure-table-striped">
<thead><tr>
{{ range split $fields "|"}}
<th>{{ . }}</th>
{{ end }}
</thead></tr>
<tbody>
{{ range $data}}
<tr>
{{ $items := split . "|" }}
{{ range $items }}
<td>{{ . }}</td>
{{ end }}
</tr>
{{ end }}
</tbody>
</table>

0 comments on commit a775981

Please sign in to comment.