mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 18:01:36 +03:00
e04af28efe
refs https://github.com/TryGhost/Team/issues/828 - This is experimental segment extraction logic, more to follow. Alllows to extract arrays of email segments used in the email's HTML content
14 lines
312 B
JavaScript
14 lines
312 B
JavaScript
const cheerio = require('cheerio');
|
|
|
|
const getSegmentsFromHtml = (html) => {
|
|
const $ = cheerio.load(html);
|
|
|
|
const allSegments = $('[data-gh-segment]')
|
|
.get()
|
|
.map(el => el.attribs['data-gh-segment']);
|
|
|
|
return allSegments;
|
|
};
|
|
|
|
module.exports.getSegmentsFromHtml = getSegmentsFromHtml;
|