-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support unescaped content, attributes and interpolation (#145)
- Loading branch information
Showing
7 changed files
with
98 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
defmodule RawOutputTest do | ||
use ExUnit.Case | ||
|
||
alias Slime.Renderer | ||
alias Phoenix.HTML | ||
alias Phoenix.HTML.Engine | ||
|
||
defp render(template, bindings \\ []) do | ||
template | ||
|> Renderer.render(bindings, engine: Engine) | ||
|> HTML.safe_to_string | ||
end | ||
|
||
test "render raw dynamic content" do | ||
slime = """ | ||
== "<>" | ||
""" | ||
assert render(slime) == "<>" | ||
end | ||
|
||
test "render raw attribute value" do | ||
slime = """ | ||
a href==href | ||
""" | ||
assert render(slime, href: "&") == ~s[<a href="&"></a>] | ||
end | ||
|
||
test "render raw tag content" do | ||
slime = """ | ||
p == "<>" | ||
""" | ||
assert render(slime) == ~s[<p><></p>] | ||
end | ||
|
||
test "render raw text interpolation" do | ||
slime = ~S""" | ||
| test #{{"<>"}} | ||
""" | ||
assert render(slime) == "test <>" | ||
end | ||
end |