BEAUTY AMP CORE
This library gives you the option to format AMPscript code used in SFMC.
Installation
> npm install --save beauty-amp-core
Usage
const beautifier = require('beauty-amp-core');
beautifier.setup(undefined, undefined, {
loggerOn: false
});
let lines = [`<h1>My Test Case:</h1>`,
`%%[ VAR @lang `,
`If (@lang == 'EN') then Output("Hello World!")`,
`Else`,
` Output("Ciao!")`,
`endif`,
`]%%`];
const result = beautifier.beautify(lines);
console.log(result);
beautify(lines)
Format code. Lines are broken on "\n"
.
lines
: Array|String - text of your code
return
: {Array|String} Formatted code. Array or string based on the initial input.
Setup
Defaults:
const ampscript = {
capitalizeAndOrNot:true,
capitalizeIfFor:true,
capitalizeSet:true,
capitalizeVar:true,
maxParametersPerLine: 4
};
const editor = {
insertSpaces: true
};
const logs = {
loggerOn: true
};
beautifier.setup(ampscript, editor, logs);