Skip to content

Commit

Permalink
HTML-35 Fix boolean attributes with literal values
Browse files Browse the repository at this point in the history
  • Loading branch information
sbsoftware committed Jun 17, 2024
1 parent 8221941 commit 4c0bc0b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions spec/instance_template/attributes_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ module ToHtml::InstanceTemplate::AttributesSpec
"Options"
end
select_tag id: SomeId.to_s, name: "myselect" do
option(value: "", selected: false) { "-" }
["one", "two", "three"].each do |val|
option(value: val, selected: val == DEFAULT_VALUE) { val }
end
end
input name: "name", type: "text", required: true
input name: "surname", type: "text", required: false
end
end

Expand Down Expand Up @@ -86,10 +89,13 @@ module ToHtml::InstanceTemplate::AttributesSpec
<fieldset>
<label for="some-id">Options</label>
<select id="some-id" name="myselect">
<option value="">-</option>
<option value="one">one</option>
<option value="two" selected>two</option>
<option value="three">three</option>
</select>
<input name="name" type="text" required>
<input name="surname" type="text">
</fieldset>
HTML

Expand Down
4 changes: 2 additions & 2 deletions src/instance_template.cr
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ module ToHtml

{% if call.named_args %}
{% for named_arg in call.named_args %}
%attr_hash[{{named_arg.name.stringify}}] = {{named_arg.value}}.to_s
%attr_hash[{{named_arg.name.stringify}}] = {{named_arg.value}}
{% end %}
{% end %}

Expand Down Expand Up @@ -210,7 +210,7 @@ module ToHtml

{% if call.named_args %}
{% for named_arg in call.named_args %}
%attr_hash[{{named_arg.name.stringify}}] = {{named_arg.value}}.to_s
%attr_hash[{{named_arg.name.stringify}}] = {{named_arg.value}}
{% end %}
{% end %}

Expand Down

0 comments on commit 4c0bc0b

Please sign in to comment.