The parent selector is not handled in the same manner as selector
interpolation. Selector interpolation is purely a textual replacement: the
text of the variable is inserted into the selector at the point of
interpolation. Parent selectors, on the other hand, need to be fully
understood by Sass. For an example of why this is the case, consider the
following:
h1, h2, h3
&.title
font-family: serif
Rather than expanding into "h1, h2, h3.title", which would happen if this
used textual replacement, it expands into "h1.title, h2.title, h3.title". In
order for this to work, Sass *must* have a full understanding of the
selectors involved, which is why you can't put & in the middle of a
selector.
On Thu, May 13, 2010 at 12:21 PM, veged <[email protected]> wrote:
> See http://github.com/nex3/haml/issues/issue/152/ for inro.
>
> Briefly, I have css-class prefixes (like namespaces) and wanna write
> many rules in one namespace without multiply repeating, e.g. for
> `.myns-elem1`, `.myns-elem2` it is very logical write:
> .myns-
> &elem1
> ...
> &elem2
> ...
>
> why `&` needs could get replaced with `*` or an element name? it's
> possible throw error only when interpolation of `&` make incorrect
> selectors (like `*smth`) and _warn_ when it make _possible_ wrong
> selectors (like `divsmth`, _warn_ because it's possible correct
> selector for custom dom-nodes).
>
> Now, with variables interpolation possible make incorrect selector,
> `#{$myvar}__subelem` produce result without any warns on any variable
> content. I.e. shortest `&__elem` is deprecated way for broke
> selectors, but longest `#{$myvar}__subelem` take possibility for same
> errors.
>
> Let's discuss about possible alternative syntax for short reference to
> parent selector...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Haml" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected] <haml%[email protected]>.
> For more options, visit this group at
> http://groups.google.com/group/haml?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Haml" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/haml?hl=en.