Skip to content

Commit

Permalink
Output <tbody> after <table>
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed Dec 6, 2021
1 parent 921c1d8 commit c19d4fb
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 90 deletions.
14 changes: 7 additions & 7 deletions lib/inky/component_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ def _transform_button(component, inner)

classes = _combine_classes(component, 'button')
expander = '<td class="expander"></td>' if expand
%{<table class="#{classes}"><tr><td><table><tr><td>#{inner}</td></tr></table></td>#{expander}</tr></table>}
%{<table class="#{classes}"><tbody><tr><td><table><tbody><tr><td>#{inner}</td></tr></tbody></table></td>#{expander}</tr></tbody></table>}
end

def _transform_menu(component, inner)
attributes = _combine_attributes(component, 'menu')
%{<table #{attributes}><tr><td><table><tr>#{inner}</tr></table></td></tr></table>}
%{<table #{attributes}><tbody><tr><td><table><tbody><tr>#{inner}</tr></tbody></table></td></tr></tbody></table>}
end

def _transform_menu_item(component, inner)
Expand Down Expand Up @@ -96,12 +96,12 @@ def _transform_columns(component, inner)
subrows = component.elements.css(".row").to_a.concat(component.elements.css("row").to_a)
expander = %{<th class="expander"></th>} if large_size.to_i == column_count && subrows.empty?

%{<#{INTERIM_TH_TAG} class="#{classes}" #{_pass_through_attributes(component)}><table><tr><th>#{inner}</th>#{expander}</tr></table></#{INTERIM_TH_TAG}>}
%{<#{INTERIM_TH_TAG} class="#{classes}" #{_pass_through_attributes(component)}><table><tbody><tr><th>#{inner}</th>#{expander}</tr></tbody></table></#{INTERIM_TH_TAG}>}
end

def _transform_block_grid(component, inner)
classes = _combine_classes(component, "block-grid up-#{component.attr('up')}")
%{<table class="#{classes}"><tr>#{inner}</tr></table>}
%{<table class="#{classes}"><tbody><tr>#{inner}</tr></tbody></table>}
end

def _transform_center(component, _inner)
Expand All @@ -121,12 +121,12 @@ def _transform_center(component, _inner)
def _transform_callout(component, inner)
classes = _combine_classes(component, 'callout-inner')
attributes = _pass_through_attributes(component)
%{<table #{attributes}class="callout"><tr><th class="#{classes}">#{inner}</th><th class="expander"></th></tr></table>}
%{<table #{attributes}class="callout"><tbody><tr><th class="#{classes}">#{inner}</th><th class="expander"></th></tr></tbody></table>}
end

def _transform_spacer(component, _inner)
classes = _combine_classes(component, 'spacer')
build_table = ->(size, extra) { %{<table class="#{classes} #{extra}"><tbody><tr><td height="#{size}" style="font-size:#{size}px;line-height:#{size}px;">&#xA0;</td></tr></tbody></table>} }
build_table = ->(size, extra) { %{<table class="#{classes} #{extra}"><tbody><tr><td height="#{size}" style="font-size:#{size}px;line-height:#{size}px;">&nbsp;</td></tr></tbody></table>} }
size = component.attr('size')
size_sm = component.attr('size-sm')
size_lg = component.attr('size-lg')
Expand All @@ -142,7 +142,7 @@ def _transform_spacer(component, _inner)

def _transform_wrapper(component, inner)
attributes = _combine_attributes(component, 'wrapper')
%{<table #{attributes} align="center"><tr><td class="wrapper-inner">#{inner}</td></tr></table>}
%{<table #{attributes} align="center"><tbody><tr><td class="wrapper-inner">#{inner}</td></tr></tbody></table>}
end
end
end
84 changes: 42 additions & 42 deletions spec/components_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@

expected = <<-HTML
<center>
<table class="float-center menu " align="center">
<table class="float-center menu " align="center"><tbody>
<tr>
<td>
<table>
<table><tbody>
<tr>
<th class="float-center menu-item">
<a href="#"></a>
</th>
</tr>
</table>
</tbody></table>
</td>
</tr>
</table>
</tbody></table>
</center>
HTML

Expand All @@ -55,53 +55,53 @@
it "creates a simple button" do
input = '<button href="http://zurb.com">Button</button>'
expected = <<-HTML
<table class="button">
<table class="button"><tbody>
<tr>
<td>
<table>
<table><tbody>
<tr>
<td><a href="http://zurb.com">Button</a></td>
</tr>
</table>
</tbody></table>
</td>
</tr>
</table>
</tbody></table>
HTML
compare(input, expected)
end

it 'creates a button with target="_blank" attribute' do
input = '<button href="http://zurb.com" target="_blank">Button</button>'
expected = <<-HTML
<table class="button">
<table class="button"><tbody>
<tr>
<td>
<table>
<table><tbody>
<tr>
<td><a href="http://zurb.com" target="_blank">Button</a></td>
</tr>
</table>
</tbody></table>
</td>
</tr>
</table>
</tbody></table>
HTML
compare(input, expected)
end

it 'creates a button with classes' do
input = '<button class="small alert" href="http://zurb.com">Button</button>'
expected = <<-HTML
<table class="button small alert">
<table class="button small alert"><tbody>
<tr>
<td>
<table>
<table><tbody>
<tr>
<td><a href="http://zurb.com">Button</a></td>
</tr>
</table>
</tbody></table>
</td>
</tr>
</table>
</tbody></table>
HTML

compare(input, expected)
Expand All @@ -110,20 +110,20 @@
it 'creates a correct expanded button' do
input = '<button class="expand" href="http://zurb.com">Button</button>'
expected = <<-HTML
<table class="button expand">
<table class="button expand"><tbody>
<tr>
<td>
<table>
<table><tbody>
<tr>
<td>
<center><a href="http://zurb.com" align="center" class="float-center">Button</a></center>
</td>
</tr>
</table>
</tbody></table>
</td>
<td class="expander"></td>
</tr>
</table>
</tbody></table>
HTML

compare(input, expected)
Expand All @@ -138,17 +138,17 @@
</menu>
INKY
expected = <<-HTML
<table class="menu">
<table class="menu"><tbody>
<tr>
<td>
<table>
<table><tbody>
<tr>
<th class="menu-item"><a href="http://zurb.com">Item</a></th>
</tr>
</table>
</tbody></table>
</td>
</tr>
</table>
</tbody></table>
HTML

compare(input, expected)
Expand All @@ -161,17 +161,17 @@
</menu>
INKY
expected = <<-HTML
<table class="menu">
<table class="menu"><tbody>
<tr>
<td>
<table>
<table><tbody>
<tr>
<th class="menu-item"><a href="http://zurb.com" target="_blank">Item</a></th>
</tr>
</table>
</tbody></table>
</td>
</tr>
</table>
</tbody></table>
HTML

compare(input, expected)
Expand All @@ -183,16 +183,16 @@
</menu>
INKY
expected = <<-HTML
<table class="menu vertical">
<table class="menu vertical"><tbody>
<tr>
<td>
<table>
<table><tbody>
<tr>
</tr>
</table>
</tbody></table>
</td>
</tr>
</table>
</tbody></table>
HTML

compare(input, expected)
Expand All @@ -205,17 +205,17 @@
</menu>
INKY
expected = <<-HTML
<table class="menu">
<table class="menu"><tbody>
<tr>
<td>
<table>
<table><tbody>
<tr>
<th class="menu-item"><a href="http://zurb.com">Item 1</a></th>
</tr>
</table>
</tbody></table>
</td>
</tr>
</table>
</tbody></table>
HTML

compare(input, expected)
Expand All @@ -226,12 +226,12 @@
it "creates a callout with correct syntax" do
input = '<callout>Callout</callout>'
expected = <<-HTML
<table class="callout">
<table class="callout"><tbody>
<tr>
<th class="callout-inner">Callout</th>
<th class="expander"></th>
</tr>
</table>
</tbody></table>
HTML

compare(input, expected)
Expand All @@ -240,12 +240,12 @@
it "copies classes to the final HTML" do
input = '<callout class="primary">Callout</callout>'
expected = <<-HTML
<table class="callout">
<table class="callout"><tbody>
<tr>
<th class="callout-inner primary">Callout</th>
<th class="expander"></th>
</tr>
</table>
</tbody></table>
HTML

compare(input, expected)
Expand Down Expand Up @@ -340,11 +340,11 @@
it 'creates a wrapper that you can attach classes to' do
input = '<wrapper class="header"></wrapper>'
expected = <<-HTML
<table class="wrapper header" align="center">
<table class="wrapper header" align="center"><tbody>
<tr>
<td class="wrapper-inner"></td>
</tr>
</table>
</tbody></table>
HTML

compare(input, expected)
Expand Down
Loading

0 comments on commit c19d4fb

Please sign in to comment.