@pcg/ugc
v0.0.3
Published
PCG UGC Module
Downloads
7
Readme
UGC
Usage
npm i @pcg/ugc
const contentV1 = `
console.log(2 + 2);
/* [UGC custom] */
/* [/UGC] */
`
const contentV2 = `
const value: number = 2 + 2;
console.log(value);
/* [UGC custom] */
/* [/UGC] */
`
const modifiedContentV1 = `
console.log(2 + 2);
/* [UGC custom] */
console.log('My custom code');
console.log(4 * 4);
/* [/UGC] */
`
const ugc = new UGC({ sourceType: 'ts' });
ugc.parse(modifiedContentV1);
const result = ugc.inject(contentV2);
/* result
const value: number = 2 + 2;
console.log(value);
/* [UGC custom] */
console.log('My custom code');
console.log(4 * 4);
/* [/UGC] */
*/
PCG
return [{
path: '/.gitignore',
tplType: 'hbs',
template: path.resolve(__dirname, './template.hbs'),
data: {
headers,
paths: this.paths,
},
ugc: 'config',
}];
Source Types
- js
- ts
- config
- html
- vue