mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-29 17:42:38 +00:00
Small fix and test updates
Discovered that classes ( and possibly other splits could end up with an empty/null member that still gets joined so I added a trim to the end of all the joins in processStyleTags. Added tests that SHOULD test for bloc-level and inline-span moustaches with added attributes ( a=b )
This commit is contained in:
@@ -359,6 +359,7 @@ const processStyleTags = (string)=>{
|
||||
|
||||
const id = _.remove(tags, (tag)=>tag.startsWith('#')).map((tag)=>tag.slice(1))[0];
|
||||
const classes = _.remove(tags, (tag)=>(!tag.includes(':')) && (!tag.includes('=')));
|
||||
console.log(classes);
|
||||
let attributes = _.remove(tags, (tag)=>(!tag.includes(':')) && (!tag.includes('#')));
|
||||
const styles = tags?.length ? tags.map((tag)=>tag.replace(/:"?([^"]*)"?/g, ':$1;').trim()) : [];
|
||||
|
||||
@@ -366,10 +367,10 @@ const processStyleTags = (string)=>{
|
||||
attributes = attributes.map((attr)=>attr.replace(/="?([^"]*)"?/g, '="$1"'));
|
||||
}
|
||||
|
||||
return `${classes.join(' ')}" ` +
|
||||
return `${classes.join(' ').trim()}" ` +
|
||||
`${id ? `id="${id}"` : ''} ` +
|
||||
`${styles?.length ? `style="${styles.join(' ')}"` : ''}` +
|
||||
`${attributes?.length ? ` ${attributes.join(' ')}` : ''}`;
|
||||
`${styles?.length ? `style="${styles.join(' ').trim()}"` : ''}` +
|
||||
`${attributes?.length ? ` ${attributes.join(' ').trim()}` : ''}`;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user