Skip to content

Commit

Permalink
ok singular tags
Browse files Browse the repository at this point in the history
  • Loading branch information
librasteve committed Jul 22, 2024
1 parent 4ede8fe commit e868190
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bin/synopsis-rahx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ say h1 :class<doobie>;

say div :class<jumbotron>, 'xx';

say br;




Expand Down
11 changes: 11 additions & 0 deletions lib/HTMX.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,24 @@ sub do-regular-tag( $tag, $inner?, *%h ) {
'<' ~ $tag ~ $attrs ~ '>' ~ ($inner // '') ~ '</' ~ $tag ~ '>'
}

sub do-singular-tag( $tag, *%h ) {

my $attrs = +%h ?? (' ' ~ %h.map({.key ~ '="' ~ .value ~ '"'}).join(' ') ) !! '';

'<' ~ $tag ~ $attrs ~ ' />'
}

# put in all the tags programmatically
# viz. https://docs.raku.org/language/modules#Exporting_and_selective_importing

my package EXPORT::DEFAULT {
for @regular-tags -> $tag {
OUR::{'&' ~ $tag} := sub ($inner?, *%h) { do-regular-tag( "$tag", $inner, |%h ) }
}

for @singular-tags -> $tag {
OUR::{'&' ~ $tag} := sub (*%h) { do-singular-tag( "$tag", |%h ) }
}
}


Expand Down

0 comments on commit e868190

Please sign in to comment.