compacted variables V can be Attribute or Element #8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I wanted to use compact HTML for a form, but could not find a way to set the
checked
attribute dynamically.Attribute
that take an argument already work nicely withV
, butCheckedA
and other booleanAttribute
don't have an argument to fill dynamically.In other words, you are left with trying to write:
This will not type check, nor should it type check. That
V @"checked"
could be anything with aConvert
instance which may not result in valid html.Still, I wanted to use compact HTML and I wanted to ensure
V @"checked"
was a validAttribute
forInput
. So, I changed:Into:
and added a new rule for the
Lawful
type familyNow I could write
and be sure that
CheckedA
was a valid attribute in this context.At the same time, I am now sure that when rendering only a
Maybe CheckedA
gets put in that variable:One nice addition to this implementation is that you do not have to specify the type:
will happily type check. In other words, you may not need to fix existing code.
Also, I added type synonyms for all
Attribute
andElement
to make specifying the type cleaner.