This repository has been archived on 2023-08-07. You can view files and clone it, but cannot push or open issues or pull requests.
temple/test/whitespace_test.exs
Mitchell Hanberg c965048f40
Better whitespace handling and control (#145)
* Fine tune whitespace

The EEx outut now emits more human-readable and predictable formatting.
This includes proper indenting, at least for each "root" template.

* Internal whitespace control

You can now use a bang version of any nonvoid tag to emit the markup
witout the internal whitespace. This means that there will not be a
newline emitted after the opening tag and before the closing tag.
2021-08-29 17:45:07 -04:00

47 lines
866 B
Elixir

defmodule Temple.WhitespaceTest do
use ExUnit.Case, async: true
import Temple
alias Temple.Support.Utils
test "only emits a single new line" do
result =
temple do
div class: "hello" do
span id: "foo" do
"Howdy, "
end
div class: "hi" do
"Jim Bob"
end
c WhoaNelly, foo: "bar" do
slot :silver do
"esketit"
end
end
end
end
|> Utils.append_new_line()
expected = ~s"""
<div class="hello">
<span id="foo">
Howdy,
</span>
<div class="hi">
Jim Bob
</div>
<%= Temple.Component.__component__ WhoaNelly, [foo: "bar"] do %>
<% {:silver, %{}} -> %>
esketit
<% end %>
</div>
"""
assert result == expected
end
end