Original attributes object
Optionalmapping: Dictionary<string | TransformArgumentMapping>Mapping configuration
Transformed attributes object
import { transformAttrs } from 'tshtml';
const input = {
href: '/page',
ngIf: 'isVisible'
};
const output = transformAttrs(input, {
ngIf: 'ng-if', // Rename
ngShow: {
to: 'ng-show',
default: false // Provide default
}
});
// Result:
// {
// href: '/page',
// 'ng-if': 'isVisible',
// 'ng-show': false
// }
Transforms an attributes object by renaming attributes, providing defaults, and applying transformations.
This is useful for normalizing attributes across different template syntaxes or frameworks (e.g., converting Angular
ngIftong-if, providing default values, etc.).