Skip to content

Commit

Permalink
[test]make it possible to use JLCodeBlock inside TmpBlock
Browse files Browse the repository at this point in the history
fix broken test
  • Loading branch information
MommaWatasu committed Feb 25, 2024
1 parent b012c32 commit 0f71120
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/block.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ function (TB::TmpBlock)(filters::Dict{String, Symbol}, autoescape::Bool)
t = typeof(content)
if isa(content, TmpStatement)
code *= "$(content.st);"
elseif isa(content, JLCodeBlock)
jl_code = replace(content.code, "\n"=>";")
code *= "txt *= begin;$jl_code;end;"
elseif isa(content, VariableBlock)
if occursin("|>", content.exp)
exp = map(strip, split(content.exp, "|>"))
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ using Test

# check Julia block inside inherited block
tmp = Template("super4.html", config=Dict("lstrip_blocks"=>true, "trim_blocks"=>true))
@test occursin("Hello from Julia", tmp()) broken = true
@test occursin("Hello from Julia", tmp())

# check TmpBlock
tmp = Template("block1.html", config=Dict("lstrip_blocks"=>true, "trim_blocks"=>true))
Expand Down
2 changes: 1 addition & 1 deletion test/super4.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "super2.html" %}

{% block inherite %}
{< "Hello from Julia" >}
{< "Hello from Julia" >}
{% endblock %}

0 comments on commit 0f71120

Please sign in to comment.