public static Block WriteOutCells(IEnumerable<CellDefinition> cells, bool header){
            string tagname = header ? "th" : "td";
            var onitem = new Block();
            foreach (CellDefinition cell in cells){
                var opentag = new ExpressionInterpolationExpression();
                ExpressionInterpolationExpression attrs = getAttributes(cell.Attributes);
                opentag.append("<" + tagname).append(attrs).append(">");
                onitem.add(opentag.writeOut());
                onitem.add(cell.Value.brailOutResolve());

                onitem.Add(("</" + tagname + ">").toLiteral().writeOut());
            }
            return onitem;
        }
Exemple #2
0
 protected override Statement ExpandImpl(MacroStatement macro){
     var result = new Block();
     Expression outvar = macro.Arguments.Count == 0 ? new ReferenceExpression("_out") : macro.Arguments[0];
     var tryer = new TryStatement();
     var protectblock = new Block();
     protectblock.add(new MethodInvocationExpression(new ReferenceExpression("_catchoutput")));
     protectblock.add(macro.Body);
     tryer.ProtectedBlock = protectblock;
     tryer.EnsureBlock =
         new Block().add(outvar.assign(new MethodInvocationExpression(new ReferenceExpression("_endcatchoutput"))));
     result.Add(outvar.assign(""));
     result.Add(tryer);
     return result;
 }
            private void buildStartTag(string tagname, IEnumerable<Expression> argsource, Block innerblock) {
                IDictionary<string, string> defaults = null;
                if (DefaultAttributes.ContainsKey(tagname)){
                    defaults = DefaultAttributes[tagname];
                }
                ExpressionInterpolationExpression args = BrailBuildingHelper.getAttributes(argsource, defaults,
                                                                                           "class",
                                                                                           "id");

                if (tagname != "bmlempty"){
                    var tag = new ExpressionInterpolationExpression();
                    tag
                        .append("<" + tagname)
                        .append(args)
                        .append(">");
                    innerblock.add(BrailBuildingHelper.WriteOut(tag));
                }
            }
            private Statement expandBmlElement(string tagname, IEnumerable<Expression> argsource,
                                               StatementCollection statements, bool usestart, bool useend){
                var innerblock = new Block();

                if (usestart){
                    buildStartTag(tagname, argsource, innerblock);
                }

                foreach (Statement statement in statements)
                {
                    
                    innerblock.add(statement);

                }
                if (useend){
                    if (tagname != "bmlempty"){
                        innerblock.add(BrailBuildingHelper.WriteOut("</" + tagname + ">"));
                    }
                }
                return innerblock;
            }