Skip to content

Instantly share code, notes, and snippets.

@mnishiguchi
Last active August 29, 2015 14:24
Show Gist options
  • Save mnishiguchi/2ecdbd8aa166f89760ef to your computer and use it in GitHub Desktop.
Save mnishiguchi/2ecdbd8aa166f89760ef to your computer and use it in GitHub Desktop.
React.js - HAML風に書く方法 ref: http://qiita.com/mnishiguchi/items/5f5cd8d9d07f56a7360c
@Records = React.createClass
#...
render: ->
<div>
<table className='table table-bordered'>
<thead>
<tr>
<th>Name</th>
<th>Vol</th>
<th>Qty</th>
<th>Subtotal</th>
<th>Room</th>
<th>Category</th>
<th>Description</th>
<th></th>
</tr>
</thead>
<tbody>
{ for record in @state.records
<Record key={record.id} record={record}
handleDeleteRecord={this.deleteRecord}
handleEditRecord={this.updateRecord} />
}
</tbody>
</table>
</div>
@Records = React.createClass
#...(中略)
render: ->
<div className='moving_records table-responsive'>
<table className='table table-bordered table-condensed'>
<thead>
<tr>
<th>Name</th>
<th>Vol</th>
<th>Qty</th>
<th>Subtotal</th>
<th>Room</th>
<th>Category</th>
<th>Description</th>
<th></th>
</tr>
</thead>
<tbody>
{ for record in @state.records
<Record key={record.id} record={record}
handleDeleteRecord={this.deleteRecord}
handleEditRecord={this.updateRecord} />
}
</tbody>
</table>
</div>
@Records = React.createClass
#...
render: ->
React.DOM.div null,
React.DOM.table
className: 'table table-bordered'
React.DOM.thead null,
React.DOM.tr null,
React.DOM.th null, 'Name'
React.DOM.th null, 'Vol'
React.DOM.th null, 'Qty'
React.DOM.th null, 'Subtotal'
React.DOM.th null, 'Room'
React.DOM.th null, 'Category'
React.DOM.th null, 'Description'
React.DOM.th null, ''
React.DOM.tbody null,
for record in @state.records
React.createElement Record,
key: record.id,
record: record,
handleDeleteRecord: @deleteRecord,
handleEditRecord: @updateRecord
@Records = React.createClass
#...
render: ->
div = React.DOM.div
table = React.DOM.table
thead = React.DOM.thead
tr = React.DOM.tr
th = React.DOM.th
tbody = React.DOM.tbody
div null,
table
className: 'table table-bordered'
thead
tr null,
th null, 'Name'
th null, 'Vol'
th null, 'Qty'
th null, 'Subtotal'
th null, 'Room'
th null, 'Category'
th null, 'Description'
th null, ''
tbody null,
for record in @state.records
React.createElement Record,
key: record.id,
record: record,
handleDeleteRecord: @deleteRecord,
handleEditRecord: @updateRecord
R = React.DOM
@Records = React.createClass
#...
render: ->
div null,
table
className: 'table table-bordered'
R.thead
R.tr null,
R.th null, 'Name'
R.th null, 'Vol'
R.th null, 'Qty'
R.th null, 'Subtotal'
R.th null, 'Room'
R.th null, 'Category'
R.th null, 'Description'
R.th null, ''
R.tbody null,
for record in @state.records
React.createElement Record,
key: record.id,
record: record,
handleDeleteRecord: @deleteRecord,
handleEditRecord: @updateRecord
@Records = React.createClass
#...(中略)
render: ->
div = React.DOM.div
hr = React.DOM.hr
table = React.DOM.table
thead = React.DOM.thead
tr = React.DOM.tr
th = React.DOM.th
tbody = React.DOM.tbody
div
className: 'moving_records table-responsive'
table
className: 'table table-bordered table-condensed'
thead
tr
th null, 'Name'
th null, 'Vol'
th null, 'Qty'
th null, 'Subtotal'
th null, 'Room'
th null, 'Category'
th null, 'Description'
th null, ''
tbody null,
for record in @state.records
React.createElement Record,
key: record.id,
record: record,
handleDeleteRecord: @deleteRecord,
handleEditRecord: @updateRecord
@Records = React.createClass
#...(中略)
render: ->
return
<div className='moving_records table-responsive'>
<table className='table table-bordered table-condensed'>
<thead>
<tr>
<th>Name</th>
<th>Vol</th>
<th>Qty</th>
<th>Subtotal</th>
<th>Room</th>
<th>Category</th>
<th>Description</th>
<th></th>
</tr>
</thead>
<tbody>
{ for record in @state.records
<Record key={record.id} record={record}
handleDeleteRecord={this.deleteRecord}
handleEditRecord={this.updateRecord} />
}
</tbody>
</table>
</div>
div
table
thead
tr
th 'Name'
th 'Vol'
th 'Qty'
th 'Subtotal'
th 'Room'
th 'Category'
th 'Description'
th ''
tbody
for record in @state.records
React.createElement Record
%div
%table
%thead
%tr
%th 'Name'
%th 'Vol'
%th 'Qty'
%th 'Subtotal'
%th 'Room'
%th 'Category'
%th 'Description'
%th ''
%tbody
= render @records
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment