Exemplo n.º 1
0
        public void Does_scan_AppHost_Service_Assemblies_in_SharpPagesFeature()
        {
            using (new AppHost().Init())
            {
                var context = new SharpPagesFeature().Init();

                Assert.That(context.ScriptMethods.Count, Is.GreaterThanOrEqualTo(2));
                var filter = (FilterExamples)context.ScriptMethods.First(x => x is FilterExamples);
                Assert.That(filter.Pages, Is.EqualTo(context.Pages));
                Assert.That(filter.AppSettings, Is.Not.Null);
            }
        }
Exemplo n.º 2
0
        public void Can_use_forEach_with_markdown()
        {
            using (new BasicAppHost().Init())
            {
                var context = new SharpPagesFeature
                {
                    Args =
                    {
                        ["items"] = new[] { "foo", "bar", "qux" }
                    }
                }.Init();

                Assert.That(new PageResult(context.OneTimePage("{{ ' - {{it}}\n' | forEach(items) | markdown }}")).Result.RemoveAllWhitespace(),
                            Is.EqualTo("<ul><li>foo</li><li>bar</li><li>qux</li></ul>".RemoveAllWhitespace()));
            }
        }
Exemplo n.º 3
0
        public void Does_not_include_protected_filters_by_default()
        {
            var context = new ScriptContext().Init();

            context.VirtualFiles.WriteFile("index.txt", "file contents");

            Assert.That(new PageResult(context.OneTimePage("{{ 'index.txt' |> includeFile }}")).Result,
                        Is.EqualTo(""));

            var feature = new SharpPagesFeature().Init();

            feature.VirtualFiles.WriteFile("index.txt", "file contents");

            Assert.That(new PageResult(context.OneTimePage("{{ 'index.txt' |> includeFile }}")).Result,
                        Is.EqualTo(""));
        }