Esempio n. 1
0
        public override void Render(RenderContext context)
        {
            var value = context.GetValue(Name);

            var lambda = value as Lambda;

            if (lambda != null)
            {
                context.Write(lambda(InnerSource()).ToString());

                return;
            }

            var helper = value as HelperProxy;

            if (helper != null)
            {
                helper(data =>
                {
                    context.Enter(this);
                    context.Push(data);

                    RenderParts(context);

                    context.Pop();
                    context.Exit();
                }, data =>
                {
                    if (Inverse != null)
                    {
                        context.Enter(Inverse);
                        context.Push(data);

                        Inverse.RenderParts(context);

                        context.Pop();
                        context.Exit();
                    }
                });

                return;
            }

            foreach (var item in context.GetValues(Name))
            {
                context.Enter(this);
                context.Push(item);

                base.Render(context);

                context.Pop();
                context.Exit();
            }
        }
Esempio n. 2
0
        public override void Render(RenderContext context)
        {
            var value = context.GetValue(Name);

            var lambda = CheckValueIsDelegateOrLambda(value);

            if (lambda != null)
            {
                var lambdaResult = lambda(InnerSource()).ToString();
                using (TextReader sr = new StringReader(lambdaResult))
                {
                    var template = new Template();
                    template.StartDelimiter = context.ActiveStartDelimiter;
                    template.EndDelimiter   = context.ActiveEndDelimiter;

                    template.Load(sr);
                    context.Enter(template);
                    template.Render(context);
                    context.Exit();
                }

                return;
            }

            var helper = value as HelperProxy;

            if (helper != null)
            {
                helper(data =>
                {
                    context.Enter(this);
                    context.Push(data);

                    RenderParts(context);

                    context.Pop();
                    context.Exit();
                }, data =>
                {
                    if (Inverse != null)
                    {
                        context.Enter(Inverse);
                        context.Push(data);

                        Inverse.RenderParts(context);

                        context.Pop();
                        context.Exit();
                    }
                });

                return;
            }

            foreach (var item in context.GetValues(Name))
            {
                context.Enter(this);
                context.Push(item);

                base.Render(context);

                context.Pop();
                context.Exit();
            }
        }