# posthtml-rename-attrs **Repository Path**: mirrors_posthtml/posthtml-rename-attrs ## Basic Information - **Project Name**: posthtml-rename-attrs - **Description**: Programmatically rename HTML attributes - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-25 - **Last Updated**: 2025-09-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README
PostHTML

posthtml-rename-attrs

Programmatically rename HTML attributes

[![Version][npm-version-shield]][npm] [![Build][github-ci-shield]][github-ci] [![License][license-shield]][license] [![Downloads][npm-stats-shield]][npm-stats]
## About This [PostHTML](https://github.com/posthtml/posthtml) plugin allows you to programmatically rename HTML attributes through a custom function. ## Installation ```sh npm i -D posthtml posthtml-rename-attrs ``` ## Usage You simply define a function that returns the renamed attribute. For example, let's rename all `src` attributes: ```js const posthtml = require('posthtml'); const renameAttrs = require('posthtml-rename-attrs'); // If the attribute is 'class', rename it const prefix = (v) => v === 'src' ? `data-${v}` : v; posthtml([renameAtrs(prefix)]) .process('') .then(function(result) { console.log(result); }); ``` Result: ```html ``` [npm]: https://www.npmjs.com/package/posthtml-rename-attrs [npm-version-shield]: https://img.shields.io/npm/v/posthtml-rename-attrs.svg [npm-stats]: http://npm-stat.com/charts.html?package=posthtml-rename-attrs [npm-stats-shield]: https://img.shields.io/npm/dt/posthtml-rename-attrs.svg [github-ci]: https://github.com/posthtml/posthtml-rename-attrs/actions/workflows/nodejs.yml [github-ci-shield]: https://github.com/posthtml/posthtml-rename-attrs/actions/workflows/nodejs.yml/badge.svg [license]: ./LICENSE [license-shield]: https://img.shields.io/npm/l/posthtml-rename-attrs.svg