Setting valueless boolean attributes with the tag function
If an attribute is set to true, it will get added without a value.
{{ tag('input', {
    id: idVar,
    name: nameVar,
    required: true
}) }}

Also, if it is set to null or false, it will be omitted, as if it was never listed in the first place.