pHTML Utility Class
pHTML Utility Class gives your markup super powers.
Example
Use to write inteligent functional classes based on their arguments.
Transforms into styles based on your configuration.
You can configure class functions to output whatever you like.
When used with a stylesheet it becomes very powerful, requiring minimal pre configuration to work with your design system.
Features
-
### Functional Class Names
Use inteligent functional class names. Seperate arguments with commas. Use a wildcard to skip arguments. See below for configuring your own class names.
-
### Inline Styles
Make use of all CSS features inline including hover states and media queries.
-
### Supports PostCSS
Add support for PostCSS by including a
postcss.config.js
file in your project.
-
### Custom Syntax
Customise the syntax used for functional classes by by overiding the default regex pattern.
phtml-utility-class.process(html, null, options)
;// Optionslet options =regex:property: /[^-\s]+/number: /[0-9]*\.?[0-9]+|\*/unit: /px|cm|mm|in|pt|pc|em|ex|ch|rem|vw|vh|vmin|vmax/seperator: /,/arg: /0*?|/args: /+/decl: /?/;
Configure
By default phtml-utility-class
will look for a file called phtml-utility-class.config.js
at the root of your project.
// phtml-utility-class.config.jsmoduleexports = classes: class: 'p' children: 't' 'r' 'b' 'l' { if argslength < 3 args else args for let i side of children str`--: ;` return } // ...
Usage
Add [phtml-utility-class] to your project:
npm install phtml-utility-class --save-dev
Use [phtml-utility-class] to process your HTML:
const phtmlUtilityClass = ; phtmlUtilityClass;
Or use it as a pHTML plugin:
const phtml = ;const phtmlUtilityClass = ; ;