private static ElementBlock GetElementBlock()
 {
     var elementShouldBeRendered = new ElementBlock(".showme");
     elementShouldBeRendered.Add(new Property("height", new Number("px", 1)));
     elementShouldBeRendered.Add(new Property("width", new Number("px", 1)));
     return elementShouldBeRendered;
 }
 public void ShouldConvertElementBlocksInLessDomToCssDom()
 {
     var root = new ElementBlock("*");
     root.Add(GetElementBlock());
     var cssDocument = converter.BuildCssDocument(root);
     Assert.That(cssDocument.Elements.Count, Is.EqualTo(1));
 }
Beispiel #3
0
 public void CanAddSubElements()
 {
     var e2 = new ElementBlock("E2");
     var element = new ElementBlock("El");
     element.Add(e2);
     Assert.That(element.Elements.Contains(e2));
 }
 public void ShouldNotConvertElementBlocksInLessDomToCssDomIfInNestedFalseIfBlock()
 {
     var root = new ElementBlock("*");
     var ifBlock = new IfBlock(new BoolExpression(new List<INode> {new Bool(false)}));
     root.Add(ifBlock);
     ifBlock.Add(GetElementBlock());
     var cssDocument = converter.BuildCssDocument(root);
     Assert.That(cssDocument.Elements.Count, Is.EqualTo(0));
 }
Beispiel #5
0
 public void CanRetrieveElementPath()
 {
     var e2 = new ElementBlock("E2");
     var e3 = new ElementBlock("E3");
     var element = new ElementBlock("El");
     element.Add(e2);
     e2.Add(e3);
     Assert.That(e3.Path().Contains(element));
 }
Beispiel #6
0
        private IEnumerable<INode> Insert(PegNode node, ElementBlock elementBlock)
        {
            node = (node.child_ ?? node);
            var path = (node).GetAsString(Src)
                .Replace("\"", "").Replace("'", "");

            if (HttpContext.Current != null){
                path = HttpContext.Current.Server.MapPath(path);
            }

            if (File.Exists(path)){
                var text = File.ReadAllText(path);
                elementBlock.Add(new Insert(text));
            }
            return new List<INode>();
        }
Beispiel #7
0
        /// <summary>
        /// declaration:  standard_declaration / catchall_declaration ;
        /// </summary>
        /// <param name="node"></param>
        /// <param name="elementBlock"></param>
        private void Declaration(PegNode node, ElementBlock elementBlock)
        {
            var name = node.GetAsString(Src).Replace(" ", "");
            var nextNode = node.next_;

            if(nextNode == null){
                // TODO: emit warning: empty declaration //
                return;
            }
            if (nextNode.ToEnLess() == EnLess.comment)
                nextNode = nextNode.next_;

            var values = Expressions(nextNode, elementBlock);
            var property = name.StartsWith("@") ? new Variable(name, values) : new Property(name, values);
            elementBlock.Add(property);
        }
Beispiel #8
0
 /// <summary>
 /// standard_ruleset: ws selectors [{] ws primary ws [}] ws;
 /// </summary>
 /// <param name="elementBlock"></param>
 /// <param name="els"></param>
 /// <returns></returns>
 private static IEnumerable<ElementBlock> StandardSelectors(ElementBlock elementBlock, IEnumerable<ElementBlock> els)
 {
     foreach (var el in els)
     {
         elementBlock.Add(el);
         elementBlock = elementBlock.Last;
     }
     yield return elementBlock;
 }