Sanity-Check for parent block

This commit is contained in:
reverend 2021-01-06 19:09:08 +01:00
parent 0292e2c872
commit 4fe2c21839

View File

@ -18,14 +18,14 @@ _get_parent_selector()
* Gets the selector of the current block
*/
_get_block_selector()
return split('__', _get_parent_selector())[0]
return unquote(split('__', _get_parent_selector())[0])
/*
* Generates a CSS class for an
* Block according to BEM
*/
RV-Block(name)
{_css-prefix}-{name}
.{_css-prefix}-{name}
{block}
/*
@ -33,7 +33,7 @@ RV-Block(name)
* according to BEM.
*/
RV-Block__Modifier(name)
&{get_block_selector()}--{name}
&{_get_block_selector()}--{name}
{block}
/*
@ -42,10 +42,9 @@ RV-Block__Modifier(name)
* For more see RV-Element___Modifier
*/
RV-Element(name)
block-selector = get_block_selector()
block-selector = _get_block_selector()
// Are we in a block?
if length(block-selector) > 0
if block-selector != '&'
//Create Selector and output the CSS for the element
{block-selector}__{name}
{block}
@ -62,7 +61,10 @@ RV-Element(name)
name: modifier['name'],
modifier_block: modifier['block']
)
else
warn('No block found. Creating One instead')
+RV-Block(name)
{block}
/*
* Generates a CSS class for an element modifier
* according to BEM. These are ment to be part of the
@ -74,7 +76,7 @@ RV-Element(name)
*/
RV-Element__Modifier(name)
callback = @(element, name, modifier_block){
&{get_block_selector()}__{element}--{name}{
&{_get_block_selector()}__{element}--{name}{
{modifier_block}
}
}