Skip to content

Latest commit

 

History

History
33 lines (33 loc) · 674 Bytes

table.md

File metadata and controls

33 lines (33 loc) · 674 Bytes

Within Pehl, using some reader like Spyc, hiccup can be generated out of YAML data:

-
  - title: rose
  - price: 1.25
-
  - daisy
  - 0.75

YAMLScript, which is written in and compiles to Clojure, looks like hiccup without the parentheses (entire code here):

defn make-table(rows)::
- <table>
- !
  for [h first(rows)]::
    - <th>
    - !
      key: (first h)
    - </th>
- !
  for [r rows]::
    - <tr>
    - !
      for [v r]::
       - <td>
       - !
         if map?(v):
           val: first(v)
           =>: v
       - </td>
    - </tr>
- </table>