..,-
This commit is contained in:
parent
fdb770fe71
commit
fac6fb4da5
@ -1,186 +1,135 @@
|
|||||||
_state = {
|
_block = {
|
||||||
stack: {}
|
stack: {}
|
||||||
|
elements: {}
|
||||||
|
block_modifiers: {}
|
||||||
|
|
||||||
element_aliases: {}
|
element_stack: () ()
|
||||||
element_modifier_aliases: {}
|
element_modifier_stack: () ()
|
||||||
block_modifier_aliases: {}
|
block_modifier_stack: () ()
|
||||||
|
|
||||||
element_alias_stack: () ()
|
current_elements: () ()
|
||||||
element_modifier_alias_stack: () ()
|
current_element_modifiers: () ()
|
||||||
block_modifier_alias_stack: () ()
|
current_block_modifiers: () ()
|
||||||
}
|
}
|
||||||
|
|
||||||
reset_state()
|
reset_block()
|
||||||
_state.stack = {}
|
_block.stack = {}
|
||||||
|
_block.elements = {}
|
||||||
|
_block.block_modifiers = {}
|
||||||
|
|
||||||
_state.element_aliases = {}
|
_block.element_stack = {}
|
||||||
_state.element_modifier_aliases = {}
|
_block.element_modifier_stack = {}
|
||||||
_state.block_modifier_aliases ={}
|
_block.block_modifier_stack = {}
|
||||||
|
|
||||||
_state.element_alias_stack = () ()
|
_block.current_elements = () ()
|
||||||
_state.element_modifier_alias_stack = () ()
|
_block.current_element_modifiers = () ()
|
||||||
_state.block_modifier_alias_stack = () ()
|
_block.current_block_modifiers = () ()
|
||||||
|
|
||||||
push_level(level)
|
|
||||||
push(_state.stack, level)
|
|
||||||
|
|
||||||
set_element_alias(name, alias)
|
|
||||||
_state.element_aliases[name] = alias
|
|
||||||
|
|
||||||
get_element_alias(name)
|
|
||||||
if name in _state.element_aliases
|
|
||||||
return _state.element_aliases[name]
|
|
||||||
else
|
|
||||||
return name
|
|
||||||
|
|
||||||
|
|
||||||
set_element_modifier_alias(name, alias)
|
_include = {
|
||||||
_state.element_modifier_aliases[name] = alias
|
elements: {}
|
||||||
|
element_modifires: {}
|
||||||
|
block_modifiers: {}
|
||||||
|
|
||||||
get_element_modifier_alias(name)
|
element_stack: {}
|
||||||
if name in _state.element_modifier_aliases
|
element_modifier_stack: {}
|
||||||
return _state.element_modifier_aliases[name]
|
block_modifier_stack: {}
|
||||||
else
|
|
||||||
return name
|
|
||||||
|
|
||||||
|
|
||||||
set_block_modifier_alias(name, alias)
|
|
||||||
_state.block_modifier_aliases[name] = alias
|
|
||||||
|
|
||||||
get_block_modifier_alias(name)
|
}
|
||||||
if name in _state.block_modifier_aliases
|
|
||||||
return _state.block_modifier_aliases[name]
|
reset_include()
|
||||||
else
|
_aliases.element_aliases = {}
|
||||||
return name
|
_aliases.element_modifires_aliases = {}
|
||||||
|
_aliases.block_modifiers_aliases = {}
|
||||||
|
|
||||||
|
_aliases.element_alias_stack = {}
|
||||||
|
_aliases.element_modifires_alias_stack = {}
|
||||||
|
_aliases.block_modifiers_alias_stack = {}
|
||||||
|
|
||||||
|
_block_map = {}
|
||||||
|
|
||||||
|
RV-Include(block_name, alias = null)
|
||||||
|
|
||||||
|
|
||||||
RV-Squash()
|
RV-Squash()
|
||||||
{block}
|
{block}
|
||||||
|
|
||||||
RV-Block(block_name)
|
RV-Block(block_name)
|
||||||
|
|
||||||
push(_block_name_stack, block_name)
|
|
||||||
|
|
||||||
last_element_selector = null
|
|
||||||
last_element_name = null
|
|
||||||
last_bock_modifier_selector = null
|
|
||||||
last_bock_modifier_name = null
|
|
||||||
|
|
||||||
selector_list = () ()
|
|
||||||
|
|
||||||
.{block_name}
|
|
||||||
|
|
||||||
{block}
|
{block}
|
||||||
|
|
||||||
for level in _state.stack
|
push(_block.elements, _block.current_elements)
|
||||||
|
push(_block.block_modifiers, _block.current_block_modifiers)
|
||||||
|
|
||||||
if level.type == 'RV-Block__Modifier'
|
_block_map[block_name] = _block
|
||||||
last_bock_modifier_name = block_name + '--' + level.name
|
|
||||||
last_bock_modifier_selector = '.' + block_name + '.' + last_bock_modifier_name
|
|
||||||
|
|
||||||
push(selector_list, {
|
reset_block()
|
||||||
selector: last_bock_modifier_selector
|
|
||||||
block_list: level.block_list
|
|
||||||
})
|
|
||||||
|
|
||||||
else
|
|
||||||
if level.type == 'RV-Element'
|
|
||||||
name = get_element_alias(level.name)
|
|
||||||
last_element_name = block_name + '__' + name
|
|
||||||
element_selector = '.' + last_element_name
|
|
||||||
|
|
||||||
if last_bock_modifier_selector != null
|
|
||||||
element_selector = last_bock_modifier_selector + ' ' + element_selector
|
|
||||||
|
|
||||||
last_element_selector = element_selector
|
|
||||||
push(selector_list, {
|
|
||||||
selector: last_element_selector
|
|
||||||
block_list: level.block_list
|
|
||||||
})
|
|
||||||
|
|
||||||
else
|
|
||||||
if level.type == 'RV-Element__Modifier'
|
|
||||||
if last_element_selector != null && last_element_name != null
|
|
||||||
modifier_selector = '.' + last_element_name + '--' + level.name
|
|
||||||
|
|
||||||
push(selector_list, {
|
|
||||||
selector: last_element_selector + modifier_selector
|
|
||||||
block_list: level.block_list
|
|
||||||
})
|
|
||||||
|
|
||||||
reset_state()
|
|
||||||
|
|
||||||
.{block_name}
|
|
||||||
for item in selector_list
|
|
||||||
if item != ()
|
|
||||||
& {item.selector}
|
|
||||||
for block in item.block_list
|
|
||||||
{block}
|
|
||||||
|
|
||||||
|
|
||||||
RV-Element(element_name)
|
RV-Element(element_name)
|
||||||
|
if 'RV-Include' in called-from
|
||||||
if 'RV-Element' in called-from
|
if 'RV-Element' in called-from
|
||||||
if lookup('block') != null
|
push(_include.element_stack, element_name)
|
||||||
push(_state.element_alias_stack, {
|
|
||||||
name: element_name,
|
|
||||||
block: block
|
|
||||||
})
|
|
||||||
else
|
else
|
||||||
|
for alias in _include.element_stack
|
||||||
|
_include.elements[alias] = element_name
|
||||||
|
_include.elements[element_name] = element_name
|
||||||
|
|
||||||
|
if 'RV-Element' in called-from
|
||||||
|
push(_state.element_stack, block)
|
||||||
|
else
|
||||||
|
element = {
|
||||||
|
type: 'RV-Element'
|
||||||
|
name: element_name
|
||||||
|
blocks: (block)
|
||||||
|
modifiers: _block.current_element_modifiers
|
||||||
|
}
|
||||||
|
_block.current_element_modifiers = () ()
|
||||||
|
|
||||||
for alias in _state.element_alias_stack
|
for child in _block.element_stack
|
||||||
set_element_alias(alias.name, element_name)
|
if child != ()
|
||||||
push(element.block_list, alias.block)
|
push(element.blocks, child)
|
||||||
_state.element_alias_stack = () ()
|
_block.element_stack = () ()
|
||||||
|
|
||||||
push_level(element)
|
if 'RV-Block__Modifier' in called-from
|
||||||
|
push(_block.current_elements, element)
|
||||||
|
else
|
||||||
|
_block.elements[elemante_name] = element
|
||||||
|
|
||||||
|
|
||||||
RV-Element__Modifier(modifier_name)
|
RV-Element__Modifier(modifier_name)
|
||||||
if 'RV-Element__Modifier' in called-from
|
if 'RV-Element__Modifier' in called-from
|
||||||
if lookup('block') != null
|
push(_state.element_modifier_stack, block)
|
||||||
push(_state.element_modifier_alias_stack, {
|
|
||||||
name: modifier_name,
|
|
||||||
block: block
|
|
||||||
})
|
|
||||||
else
|
else
|
||||||
modifier = {
|
modifier = {
|
||||||
type: 'RV-Element__Modifier'
|
type: 'RV-Element__Modifier'
|
||||||
name: modifier_name
|
name: modifier_name
|
||||||
block_list: ()
|
blocks: (block)
|
||||||
}
|
}
|
||||||
|
|
||||||
if lookup('block') != null
|
for child in _block.element_modifier_stack
|
||||||
push(modifier.block_list, block)
|
if child != ()
|
||||||
|
push(modifier.blocks, child)
|
||||||
|
_block.element_modifier_stack = () ()
|
||||||
|
|
||||||
for alias in _state.element_modifier_alias_stack
|
push(_block.current_element_modifiers, modifier)
|
||||||
if alias != ()
|
|
||||||
set_element_modifier_alias(alias.name, modifier_name)
|
|
||||||
push(modifier.block_list, alias.block)
|
|
||||||
_state.element_modifier_alias_stack = () ()
|
|
||||||
|
|
||||||
push_level(modifier)
|
|
||||||
|
|
||||||
RV-Block__Modifier(modifier_name)
|
RV-Block__Modifier(modifier_name)
|
||||||
if 'RV-Block__Modifier' in called-from
|
if 'RV-Block__Modifier' in called-from
|
||||||
if lookup('block') != null
|
push(_block.block_modifier_stack, block)
|
||||||
push(_state.block_modifier_alias_stack, {
|
|
||||||
name: modifier_name,
|
|
||||||
block: block
|
|
||||||
})
|
|
||||||
else
|
else
|
||||||
modifier = {
|
modifier = {
|
||||||
type: 'RV-Block__Modifier'
|
type: 'RV-Block__Modifier'
|
||||||
name: modifier_name
|
name: modifier_name
|
||||||
block_list: ()
|
blocks: (block)
|
||||||
|
elements: _block.current_elements
|
||||||
}
|
}
|
||||||
|
_block.current_elements = () ()
|
||||||
|
|
||||||
if lookup('block') != null
|
for child in _block.block_modifier_stack
|
||||||
push(modifier.block_list, block)
|
if child != ()
|
||||||
|
push(modifier.blocks, child)
|
||||||
|
_block.block_modifier_stack = () ()
|
||||||
|
|
||||||
for alias in _state.block_modifier_alias_stack
|
_block.block_modifiers[modifier_name] = modifier
|
||||||
if alias != ()
|
|
||||||
set_block_modifier_alias(alias.name, modifier_name)
|
|
||||||
push(modifier.block_list, alias.block)
|
|
||||||
_state.block_modifier_alias_stack = () ()
|
|
||||||
|
|
||||||
push_level(modifier)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user