Exemple #1
0
        //so what are we tsting
        //block name == blcok name
        //block followed by block
        //block followed by ; with block
        //attribute name/values
        //parameter name/values
        public static Document Parse(string text)
        {
            Parser parser = new Parser();
            Document document;

            parser.Parse(text, out document);

            return document;
        }
Exemple #2
0
        internal Document LoadDocument(string template)
        {
            Parser parser = new Parser();
            Document document;

            if (parser.Parse(template, out document))
            {
                return document;
            }

            throw new Exception("Unable to parse: ");
        }
Exemple #3
0
        public ActionResult Index(string template, string model)
        {
            if (string.IsNullOrWhiteSpace(template) || string.IsNullOrWhiteSpace(model))
            {
                return View(Tuple.Create(DefaultHtmlTemplate, DefaultModelTemplate, ""));
            }

            Parser.Parser parser = new Parser.Parser();

            Type T = TypeBuilderFromJson.CreateType(Newtonsoft.Json.JsonConvert.DeserializeObject(model) as JObject);

            var modelObject = Newtonsoft.Json.JsonConvert.DeserializeObject(model, T);

            Document document;
            string result = null;
            if (parser.Parse(template, out document))
            {
                StringBuilder sb = new StringBuilder();
                foreach (var element in document.Children)
                {
                    if (element != null)
                    {
                        var renderer =
                        Parrot.Infrastructure.Host.DependencyResolver.Get<IRendererFactory>().GetRenderer(
                        element.BlockName);
                        sb.AppendLine(renderer.Render(element, modelObject));
                    }
                }

                result = sb.ToString();
            }
            else
            {
                result = parser.ErrorString;
            }

            return View(Tuple.Create(template, model, result));
        }
        //so what are we tsting
        //block name == blcok name
        //block followed by block
        //block followed by ; with block
        //attribute name/values
        //parameter name/values
        private Document Parse(string text)
        {
            Parser.Parser parsr = new Parser.Parser();
            Document document;

            parsr.Parse(text, out document);

            return document;
        }