Exemple #1
0
        public RazorRenderer(MarkdownTransformer markdownTransformer, Logger logger)
        {
            this.markdownTransformer = markdownTransformer;
            this.logger = logger;

            this.compiler = new RazorCompiler();
            this.compiler.NamespaceImports.Add("System.Linq");
            this.compiler.NamespaceImports.Add("Gatsby");

            this.includes = new Dictionary<string, Include>();
            this.layouts = new Dictionary<string, Layout>();
        }
Exemple #2
0
        internal override void Run(
            Config config,
            MarkdownTransformer markdownTransformer,
            string relativePath,
            RazorRenderer razorRenderer,
            Site site)
        {
            base.Run(config, markdownTransformer, relativePath, razorRenderer, site);

            if (!string.IsNullOrEmpty(config.ExcerptSeparator))
            {
                if (this.Content.Contains(config.ExcerptSeparator))
                {
                    this.Excerpt = this.Content.Substring(0, this.Content.IndexOf(config.ExcerptSeparator));
                }
                else
                {
                    this.Excerpt = this.Content;
                }
            }
        }
Exemple #3
0
        internal virtual void Run(
            Config config,
            MarkdownTransformer markdownTransformer,
            string relativePath,
            RazorRenderer razorRenderer,
            Site site)
        {
            if (this.Content != null)
                throw new InvalidOperationException("Template has already been run.");

            this.RelativePath = relativePath;
            this.InitGatsbyRazorTemplate(razorRenderer, site);

            try
            {
                this.Content = this.ExecuteTemplate();
            }
            catch (Exception ex)
            {
            }

            if (this.IsMarkdown)
                this.Content = markdownTransformer.Transform(this.Content);
        }