Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/eex/lib/eex/compiler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ defmodule EEx.Compiler do
scope,
state
) do
if mark != '=' do
message =
"the contents of this expression won't be output unless the EEx block starts with \"<%=\""

:elixir_errors.erl_warn(start_line, state.file, message)
end

{contents, line, rest} = look_ahead_middle(rest, start_line, chars)

{contents, rest} =
Expand Down
9 changes: 9 additions & 0 deletions lib/eex/test/eex/smart_engine_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ defmodule EEx.SmartEngineTest do
assert_received :found
end

test "error with unused \"do\" block without \"<%=\" modifier" do
stderr =
ExUnit.CaptureIO.capture_io(:stderr, fn ->
assert_eval("", "<% if true do %>I'm invisible!<% end %>", assigns: %{})
end)

assert stderr =~ "the contents of this expression won't be output"
end

defp assert_eval(expected, actual, binding \\ []) do
result = EEx.eval_string(actual, binding, file: __ENV__.file, engine: EEx.SmartEngine)
assert result == expected
Expand Down