Handle expressions with do blocks that aren't if/unless/for
This commit is contained in:
parent
3c787297e5
commit
1f599f5f6d
3 changed files with 25 additions and 3 deletions
|
@ -2,6 +2,10 @@
|
|||
|
||||
## Master
|
||||
|
||||
## 0.6.0-alpha.3
|
||||
|
||||
- Compile functions/macros that take blocks that are not if/unless/for
|
||||
|
||||
## 0.6.0-alpha.2
|
||||
|
||||
### Component API
|
||||
|
|
|
@ -393,9 +393,16 @@ defmodule Temple.Parser do
|
|||
end
|
||||
},
|
||||
%{
|
||||
name: :for_if_unless,
|
||||
applicable?: fn {name, _, _} ->
|
||||
name in [:for, :if, :unless]
|
||||
name: :do_expressions,
|
||||
applicable?: fn
|
||||
{_, _, [_, [{:do, _} | _]]} ->
|
||||
true
|
||||
|
||||
{_, _, [[{:do, _} | _]]} ->
|
||||
true
|
||||
|
||||
{_, _, _} ->
|
||||
false
|
||||
end,
|
||||
parse: fn {name, meta, args}, buffer ->
|
||||
import Temple.Parser.Private
|
||||
|
|
|
@ -342,4 +342,15 @@ defmodule TempleTest do
|
|||
|
||||
assert result == ~s{<div class="<%= [class: "boom"][:class] %>">yay!</div>}
|
||||
end
|
||||
|
||||
test "normal functions with blocks should be treated like if expressions" do
|
||||
result =
|
||||
temple do
|
||||
leenk to: "/route", class: "foo" do
|
||||
div class: "hi"
|
||||
end
|
||||
end
|
||||
|
||||
assert result == ~s{<%= leenk(to: "/route", class: "foo") do %><div class="hi"></div><% end %>}
|
||||
end
|
||||
end
|
||||
|
|
Reference in a new issue