trucks-transform-trim
v1.0.5
Published
Trim inline styles and scripts
Readme
Trim Transform
Removes whitespace from inline content
Designed to prettify inline content so that styles and scripts have leading whitespace removed:
<dom-module id="x-blog-post">
<script>
skate.define('{{id}}', {});
</script>
</dom-module>Yields script content without the leading indentation:
skate.define('{{id}}', {});Using this transform is not typically necessary as you would ordinarily build to a minified file (possibly with source maps) however it is used internally to simplify test assertions.
Install
npm i trucks-transform-trim --save-devFor the command line interface see trucks-cli.
Usage
Use the trim key to configure this transform:
const trucks = require('trucks');
trucks(
{
files: ['components.html'],
transforms: ['trim'],
conf: {
transforms: {
trim: {
lines: false
}
}
}
}, (err, res) => {
if(err) {
throw err;
}
console.log(res);
}
);API
trim
public trim(state, conf)Removes leading and trailing whitespace from inline styles and scripts.
When the lines option is given each line is stripped of leading
whitespace that matches the pattern regular expression.
Returns map of visitor functions.
stateObject compiler state.confObject transform plugin configuration.
Options
inlineBoolean=true only replace inline elements.linesBoolean=true strip each line.patternRegExp used for line whitespace.templatesBoolean=false also trim template elements.
License
MIT
Created by mkdoc on July 18, 2016
