Example #1
0
        public override void WriteOutput(OutputContext context)
        {
            if (Block.RuleCount == 0)
            {
                return;
            }


            if (context.IsReference)
            {
                var extenderSelectorList = new SelectorList(Selectors.Selectors.SelectMany(s => context.Extensions.GetExtensions(s, includeReferences: false)));
                if (extenderSelectorList.IsEmpty())
                {
                    return;
                }

                context.Append(extenderSelectorList);
            }
            else
            {
                context.Append(Selectors);
            }

            context.AppendOptional(' ');
            context.AppendLine("{");
            context.Append(Block);
            context.Indent();
            context.AppendLine("}");
        }
Example #2
0
        public SelectorList Inherit(SelectorList parent)
        {
            IEnumerable <Selector> InheritSelectors()
            {
                foreach (var selector in selectors)
                {
                    foreach (var generatedSelector in selector.Inherit(parent))
                    {
                        yield return(generatedSelector);
                    }
                }
            }

            if (parent.IsEmpty())
            {
                return(this);
            }

            return(new SelectorList(InheritSelectors()));
        }