0.3.7 • Published 3 years ago

beauty-amp-core v0.3.7

Weekly downloads
-
License
BSD-4-CLAUSE
Repository
github
Last release
3 years ago

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); // returns code as an array

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:

// immutable at the moment:
const ampscript = {
  capitalizeAndOrNot:true,
  capitalizeIfFor:true,
  capitalizeSet:true,
  capitalizeVar:true,
  maxParametersPerLine: 4
};
// immutable at the moment:
const editor = {
  insertSpaces: true,
  tabSize: 4
};
// logs trough console only for the moment.
const logs = {
  loggerOn: true // <= disable logging
};

beautifier.setup(ampscript, editor, logs);
0.3.6

3 years ago

0.3.7

3 years ago

0.3.5

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago