Alias Problems and Optin
This commit is contained in:
parent
08e20dfcb3
commit
e8609fe833
@ -52,13 +52,20 @@ is_direct_descendant_of_block()
|
||||
return false
|
||||
return true
|
||||
|
||||
/*
|
||||
* Checks if we are called inside a block
|
||||
*/
|
||||
is_in_block()
|
||||
return 'RV-Block' in called-from
|
||||
|
||||
/*
|
||||
* Taking the currently stashed names, mapping
|
||||
* them to the given name under the called parent
|
||||
* (using called-from) and returning the stashed blocks
|
||||
*/
|
||||
generate_aliases(actual_name)
|
||||
level_type = split(' ', called-from)[0]
|
||||
generate_aliases(actual_name, level_type=null)
|
||||
if level_type == null
|
||||
level_type = split(' ', called-from)[0]
|
||||
if actual_name == null
|
||||
if length(_block.alias.stash[level_type]) > 2
|
||||
actual_name = _block.alias.stash[level_type][-1].name
|
||||
@ -82,22 +89,29 @@ generate_aliases(actual_name)
|
||||
* (using called-from). Returning the given name
|
||||
* when no alias is found
|
||||
*/
|
||||
resolve_alias(name)
|
||||
level_type = split(' ', called-from)[0]
|
||||
resolve_alias(name, level_type=null)
|
||||
if level_type == null
|
||||
level_type = split(' ', called-from)[0]
|
||||
|
||||
if level_type+':'+name in _block.alias.map
|
||||
return _block.alias.map[level_type+':'+name]
|
||||
else
|
||||
return name
|
||||
|
||||
/*
|
||||
* Renders an element modifier
|
||||
*/
|
||||
render_element_modifier(modifier)
|
||||
&--{resolve_alias(modifier.name)}
|
||||
&--{resolve_alias(modifier.name, 'RV-Element__Modifier')}
|
||||
foreach(modifier.blocks, @(block){
|
||||
{block}
|
||||
})
|
||||
|
||||
/*
|
||||
* Renders an element
|
||||
*/
|
||||
render_element(element)
|
||||
&__{resolve_alias(element.name)}
|
||||
&__{resolve_alias(element.name, 'RV-Element')}
|
||||
foreach(element.blocks, @(block){
|
||||
{block}
|
||||
})
|
||||
@ -105,8 +119,11 @@ render_element(element)
|
||||
render_element_modifier(modifier)
|
||||
})
|
||||
|
||||
/*
|
||||
* Renders an block modifier,
|
||||
*/
|
||||
render_block_modifier(modifier)
|
||||
&--{resolve_alias(modifier.name)}
|
||||
&--{resolve_alias(modifier.name, 'RV-Block__Modifier')}
|
||||
foreach(modifier.blocks, @(block){
|
||||
{block}
|
||||
})
|
||||
@ -123,22 +140,31 @@ render_block_modifier(modifier)
|
||||
* (See generate_aliases)
|
||||
*/
|
||||
RV-Element--name(name)
|
||||
push(_block.alias.stash.RV-Element, {
|
||||
name: name
|
||||
block: block
|
||||
})
|
||||
if 'RV-Element' in called-from
|
||||
push(_block.alias.stash.RV-Element, {
|
||||
name: name
|
||||
block: block
|
||||
})
|
||||
else
|
||||
{block}
|
||||
|
||||
RV-Element__Modifier--name(name)
|
||||
push(_block.alias.stash.RV-Element__Modifier, {
|
||||
name: name
|
||||
block: block
|
||||
})
|
||||
if 'RV-Element__Modifier' in called-from
|
||||
push(_block.alias.stash.RV-Element__Modifier, {
|
||||
name: name
|
||||
block: block
|
||||
})
|
||||
else
|
||||
{block}
|
||||
|
||||
RV-Block__Modifier--name(name)
|
||||
push(_block.alias.stash.RV-Block__Modifier, {
|
||||
name: name
|
||||
block: block
|
||||
})
|
||||
if 'RV-Block__Modifier' in called-from
|
||||
push(_block.alias.stash.RV-Block__Modifier, {
|
||||
name: name
|
||||
block: block
|
||||
})
|
||||
else
|
||||
{block}
|
||||
|
||||
|
||||
RV-Block(block_name)
|
||||
@ -149,11 +175,12 @@ RV-Block(block_name)
|
||||
})
|
||||
foreach(_block.elements, @(element){
|
||||
render_element(element)
|
||||
})
|
||||
})
|
||||
|
||||
reset_block()
|
||||
|
||||
|
||||
RV-Block__Modifier(modifier_name=null)
|
||||
modifier_name = resolve_alias(modifier_name)
|
||||
blocks = generate_aliases(modifier_name)
|
||||
modifier_name = blocks.name
|
||||
blocks = blocks.blocks
|
||||
@ -169,7 +196,6 @@ RV-Block__Modifier(modifier_name=null)
|
||||
push(_block.block_modifiers, modifier)
|
||||
|
||||
RV-Element(element_name=null)
|
||||
element_name = resolve_alias(element_name)
|
||||
blocks = generate_aliases(element_name)
|
||||
|
||||
element_name = blocks.name
|
||||
@ -190,7 +216,6 @@ RV-Element(element_name=null)
|
||||
|
||||
|
||||
RV-Element__Modifier(modifier_name=null)
|
||||
modifier_name = resolve_alias(modifier_name)
|
||||
blocks = generate_aliases(modifier_name)
|
||||
modifier_name = blocks.name
|
||||
blocks = blocks.blocks
|
||||
|
Loading…
Reference in New Issue
Block a user