Ejemplo n.º 1
0
        public override BlockClosingAction Render(ViewSourceReader viewSourceReader, TemplateOptions options, TemplateClassBuilder builder)
        {
            var partialName = viewSourceReader.CurrentInputLine.NormalizedText.Trim();

            if (string.IsNullOrEmpty(partialName))
            {
                if (viewSourceReader.ViewSourceQueue.Count == 0)
                {
                    throw new InvalidOperationException(NoPartialName);
                }
                var templatePath = viewSourceReader.ViewSourceQueue.Dequeue();
                viewSourceReader.MergeTemplate(templatePath, true);
            }
            else
            {
                partialName = partialName.Insert(partialName.LastIndexOf(@"\", StringComparison.OrdinalIgnoreCase) + 1, "_");
                IViewSource viewSource;
                try
                {
                    viewSource = options.TemplateContentProvider.GetViewSource(partialName, viewSourceReader.ViewSources);
                }
                catch (FileNotFoundException)
                {
                    //ToDo: render content behind the ? tag
                    viewSource = null;
                }
                viewSourceReader.ViewSourceModifiedChecks.Add(() => viewSource.IsModified);
                viewSourceReader.MergeTemplate(viewSource, true);
            }

            return EmptyClosingAction;
        }
Ejemplo n.º 2
0
        public TemplateParser(TemplateOptions options, TemplateClassBuilder templateClassBuilder, IList<IViewSource> viewSources)
        {
            BlockClosingActions = new Stack<BlockClosingAction>();

            viewSourceReader = new ViewSourceReader(options, viewSources);
            Options = options;
            builder = templateClassBuilder;
        }
Ejemplo n.º 3
0
        public TemplateParser(TemplateOptions options, TemplateClassBuilder templateClassBuilder, IList <IViewSource> viewSources)
        {
            BlockClosingActions = new Stack <BlockClosingAction>();

            viewSourceReader = new ViewSourceReader(options, viewSources);
            Options          = options;
            builder          = templateClassBuilder;
        }