diff options
author | German M. Bravo <german.mb@deipi.com> | 2012-01-09 19:12:04 -0600 |
---|---|---|
committer | German M. Bravo <german.mb@deipi.com> | 2012-01-09 19:12:04 -0600 |
commit | e103d9c88b0a9eaea567dca0ea6122c9563aadc9 (patch) | |
tree | bb976c63693a7c9b114add9e56b7d3305fc9ff32 | |
parent | 867a3fb5330800a4bbafd665cd7630deed643328 (diff) | |
download | pyscss-e103d9c88b0a9eaea567dca0ea6122c9563aadc9.tar.gz |
Added reject() compass helper function
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | README.rst | 1 | ||||
-rw-r--r-- | scss/__init__.py | 42 |
3 files changed, 36 insertions, 8 deletions
@@ -3,6 +3,7 @@ Changelog 1.1.4 ??? + Added ``--debug-info`` command line option (for *FireSass* output). + + Added compass helper function ``reject()``. 1.1.3 Jan 9, 2012 + Support for the new Sass 3.2.0 features (``@content`` and placeholder selectors) @@ -274,6 +274,7 @@ Changelog 1.1.4 ??? + Added ``--debug-info`` command line option (for *FireSass* output). + + Added compass helper function ``reject()``. 1.1.3 Jan 9, 2012 + Support for the new Sass 3.2.0 features (``@content`` and placeholder selectors) diff --git a/scss/__init__.py b/scss/__init__.py index f1eebc3..3d67ccc 100644 --- a/scss/__init__.py +++ b/scss/__init__.py @@ -3296,9 +3296,15 @@ def _grad_point(*p): def __compass_list(*args): + separator = None if len(args) == 1 and isinstance(args[0], (list, tuple, ListValue)): args = ListValue(args[0]).values() - return ListValue(args) + else: + separator = ',' + ret = ListValue(args) + if separator: + ret['_'] = separator + return ret def __compass_space_list(*lst): @@ -3333,9 +3339,35 @@ def _compact(*args): elif bool(args): ret[0] = args else: + ret['_'] = ',' for i, item in enumerate(args): if bool(item): ret[i] = item + if isinstance(args, ListValue): + args = args.value + if isinstance(args, dict): + separator = args.get('_', None) + if separator is not None: + ret['_'] = separator + return ListValue(ret) + + +def _reject(lst, *values): + """Removes the given values from the list""" + ret = {} + if not isinstance(lst, ListValue): + lst = ListValue(lst) + lst = lst.value + if len(values) == 1: + values = values[0] + if isinstance(values, ListValue): + values = values.value.values() + for i, item in lst.items(): + if item not in values: + ret[i] = item + separator = lst.get('_', None) + if separator is not None: + ret['_'] = separator return ListValue(ret) @@ -4540,6 +4572,7 @@ fnct = { '-compass-space-list:n': __compass_space_list, 'blank:n': _blank, 'compact:n': _compact, + 'reject:n': _reject, '-compass-slice:3': __compass_slice, 'nth:2': _nth, 'max:n': _max, @@ -4619,13 +4652,6 @@ def call(name, args, R, is_function=True): else: fn = fnct.get(_fn_a) or fnct[_fn_n] node = fn(*_args, **_kwargs) - if args and isinstance(node, ListValue): - separator = args.value.get('_') - if separator is not None: - if separator: - node.value['_'] = separator - else: - node.value.pop('_', None) except KeyError: sp = args and args.value.get('_') or '' if is_function: |