Skip to content

Instantly share code, notes, and snippets.

@shgtkshruch
Created January 30, 2014 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shgtkshruch/8705343 to your computer and use it in GitHub Desktop.
Save shgtkshruch/8705343 to your computer and use it in GitHub Desktop.
create table by jade mixin
<table class="orenge">
<tbody>
<tr>
<th class="apple">name</th>
<th class="apple">birthday</th>
<th class="apple">tel</th>
<th class="apple">mail</th>
</tr>
<tr>
<td class="cherry">shgtkshruch</td>
<td class="cherry">Thu Jun 15 2000 09:00:00 GMT+0900 (JST)</td>
<td class="cherry">090-1010-2020</td>
<td class="cherry">example@email.com</td>
</tr>
<tr>
<td class="cherry">shgtkshruch</td>
<td class="cherry">Thu Jun 15 2000 09:00:00 GMT+0900 (JST)</td>
<td class="cherry">090-1010-2020</td>
<td class="cherry">example@email.com</td>
</tr>
</tbody>
</table>
include ./mixin.jade
+table_th(index.table).orenge.apple.cherry
index:
table:
th:
- name
- birthday
- tel
- mail
td:
- td:
- shgtkshruch
- 2000-06-15
- 090-1010-2020
- example@email.com
- td:
- shgtkshruch
- 2000-06-15
- 090-1010-2020
- example@email.com
mixin table_th(table_name)
- var classString = attributes.class
- var classArray = classString.split(' ')
table(class= classArray[0] === 'n' ? '' : classArray[0])
tr
each th in table_name.th
th(class= classArray[1] === 'n' ? '' : classArray[1])= th
each t in table_name.td
tr
each td, i in t.td
td(class= classArray[2] === 'n' ? '' : classArray[2])= td
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment