Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/context #61

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions bemto.jade
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- var bemto_settings_element = '__'
- var bemto_settings_modifier = '_'
- var bemto_settings_default_tag = 'div'
- var bemto_settings_context_replace = true

//- Tag mixin, used for tweaking what tag we are throwing and do we need to wrap anything here
mixin bemto_tag(tag)
Expand All @@ -15,13 +16,14 @@ mixin bemto_tag(tag)
- var contextIndex = bemto_chain_contexts.length;

//- Checks for contexts if no tag given
if !tag
if bemto_chain_contexts[contextIndex-1] === 'inline'
- newTag = 'span';
else if bemto_chain_contexts[contextIndex-1] === 'list'
- newTag = 'li';
else if bemto_chain_contexts[contextIndex-1] === 'optionlist'
- newTag = 'option';
if bemto_settings_context_replace
if !tag
if bemto_chain_contexts[contextIndex-1] === 'inline'
- newTag = 'span';
else if bemto_chain_contexts[contextIndex-1] === 'list'
- newTag = 'li';
else if bemto_chain_contexts[contextIndex-1] === 'optionlist'
- newTag = 'option';

//- Attributes context checks
if attributes.href
Expand Down
3 changes: 3 additions & 0 deletions test/cases/9_context.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<a class="link">
<div class="link__element">
</div><a class="link__element"></a></a>
6 changes: 6 additions & 0 deletions test/cases/9_context.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include ../../bemto
- bemto_settings_context_replace = false

+b('a').link
+e.element
+e('a').element