diff --git a/test/tests_markdown_rendering.jl b/test/tests_markdown_rendering.jl new file mode 100644 index 000000000..3328ea9db --- /dev/null +++ b/test/tests_markdown_rendering.jl @@ -0,0 +1,43 @@ +@safetestset "Markdown rendering" begin + + @safetestset "String markdown rendering" begin + using Genie + using Genie.Renderer.Html + using Markdown + + view = raw""" +# Hello +## Welcome to Genie""" |> Markdown.parse + + @test (Html.html(view, forceparse = true).body |> String) == "

Hello

Welcome to Genie

" + + view = raw""" +# Hello +## Welcome to Genie, $name""" |> Markdown.parse + + @test (Html.html(view, name = "John").body |> String) == "

Hello

Welcome to Genie, John

" + + layout = raw""" +
+

Layout header

+
+ <% @yield %> +
+ +
""" + + @test (Html.html(view, layout = layout, name = "John").body |> String) == "

Layout header

Hello

Welcome to Genie, John

" + end; + + @safetestset "Template markdown rendering" begin + using Genie, Genie.Renderer + using Genie.Renderer.Html + + @test Html.html(filepath("views/view.jl.md"), numbers = [1, 1, 2, 3, 5, 8, 13]).body |> String == "

There are 7

-> 1 -> 1 -> 2 -> 3 -> 5 -> 8 -> 13

" + @test Html.html(filepath("views/view.jl.md"), layout = filepath("views/layout.jl.html"), numbers = [1, 1, 2, 3, 5, 8, 13]).body |> String == + "

Layout header

There are 7

-> 1 -> 1 -> 2 -> 3 -> 5 -> 8 -> 13

" + end + +end; \ No newline at end of file diff --git a/test/views/layout.jl.html b/test/views/layout.jl.html new file mode 100644 index 000000000..f319857a7 --- /dev/null +++ b/test/views/layout.jl.html @@ -0,0 +1,9 @@ +
+

Layout header

+
+ <% @yield %> +
+ +
\ No newline at end of file diff --git a/test/views/view.jl.md b/test/views/view.jl.md new file mode 100644 index 000000000..0ea23b0a9 --- /dev/null +++ b/test/views/view.jl.md @@ -0,0 +1,8 @@ +# There are $(length(numbers)) + +$( + @foreach(numbers) do number + " -> $number + " + end +) \ No newline at end of file