Skip to content

Commit

Permalink
close issue #114 (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
jverzani authored May 27, 2020
1 parent 52963f4 commit a69484a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Mustache"
uuid = "ffc61752-8dc7-55ee-8c37-f3e9cdd09e70"
version = "1.0.2"
version = "1.0.3"

[deps]
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Expand Down
6 changes: 5 additions & 1 deletion src/tokens.jl
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ function make_tokens(template, tags)
scan_past!(io, rtags)

# what kinda tag did we get?
token_value = stripWhitespace(token_value)
_type = token_value[1:1]
if _type in ("#", "^", "/", ">", "<", "!", "|", "=", "{", "&")
# type is first, we peel it off, also strip trailing = and },
Expand All @@ -267,6 +268,10 @@ function make_tokens(template, tags)
# strip "}" if present in io
c = peekchar(io)
c == '}' && read(io, Char)
# strip "}" if present in token
if token_value[end]=='}'
token_value = token_value[1:end-1]
end
end

if _type == "="
Expand Down Expand Up @@ -330,7 +335,6 @@ function make_tokens(template, tags)
end

end

push!(tokens, text_token)
push!(tokens, tag_token)

Expand Down
12 changes: 7 additions & 5 deletions test/Mustache_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ filepath = joinpath(@__DIR__, "test-sections-crlf.tpl")
tpl = "[[#list]][[ item ]] [[/list]]"
@test Mustache.render(tpl, v, tags=("[[", "]]")) == "one two "

## Issue 104, bad nesting (needed to pop context)
tpl1 = mt"""
## Issue 104, bad nesting (needed to pop context)
tpl1 = mt"""
{{#nested.vec}}
{{.}}
{{/nested.vec}}
Expand All @@ -170,8 +170,10 @@ tpl2 = mt"""
{{/nested}}
{{nested.foo}}
"""
data2 = Dict("nested" => Dict("vec" => [1,2], "foo" => "bar"))
@test Mustache.render(tpl1, data2) == "1\n2\nbar\n"
@test Mustache.render(tpl2, data2) == "1\n2\nbar\nbar\n"
data2 = Dict("nested" => Dict("vec" => [1,2], "foo" => "bar"))
@test Mustache.render(tpl1, data2) == "1\n2\nbar\n"
@test Mustache.render(tpl2, data2) == "1\n2\nbar\nbar\n"

## Issue 114 Combine custom tags with no HTML escaping
@test Mustache.render("\$[[{JL_VERSION_MATRIX}]]", Dict("JL_VERSION_MATRIX"=>"&"), tags=("\$[[","]]")) == "&"
end

2 comments on commit a69484a

@jverzani
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/15476

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.3 -m "<description of version>" a69484a7f26ffd5e385fe97dd9663c4635f1c1d0
git push origin v1.0.3

Please sign in to comment.