Skip to content

Commit

Permalink
Allow creating custom tag with name and hash only (#1453)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewmcgarvey authored Apr 2, 2021
1 parent 28e7284 commit be767a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions spec/lucky/custom_tags_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ describe Lucky::CustomTags do
.to_s.should contain "<foo-tag></foo-tag>"
view(&.tag("foo-tag", class: "my-class"))
.to_s.should contain %(<foo-tag class="my-class"></foo-tag>)
view(&.tag("foo-tag", {"class" => "my-class"}))
.to_s.should contain %(<foo-tag class="my-class"></foo-tag>)
view(&.tag("foo-tag", attrs: [:ng_strict_di], ng_app: "ngAppStrictDemo", name: "JSApp"))
.to_s.should contain %(<foo-tag ng-app="ngAppStrictDemo" name="JSApp" ng-strict-di></foo-tag>)

Expand Down
8 changes: 8 additions & 0 deletions src/lucky/tags/custom_tags.cr
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ module Lucky::CustomTags
end
end

def tag(
tag_name : String,
options = EMPTY_HTML_ATTRS,
**other_options
) : Nil
tag(tag_name, "", options, **other_options)
end

def tag(tag_name : String, attrs : Array(Symbol) = [] of Symbol, options = EMPTY_HTML_ATTRS, **other_options, &block) : Nil
merged_options = merge_options(other_options, options)
tag_attrs = build_tag_attrs(merged_options)
Expand Down

0 comments on commit be767a7

Please sign in to comment.