-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f690a94
commit 1fc76f0
Showing
16 changed files
with
166 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# This file is responsible for configuring your application | ||
# and its dependencies with the aid of the Config module. | ||
# | ||
# This configuration file is loaded before any dependency and | ||
# is restricted to this project. | ||
|
||
# General application configuration | ||
import Config | ||
|
||
config :logger, :level, :debug | ||
config :logger, :backends, [] | ||
|
||
import_config "#{config_env()}.exs" |
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,23 @@ | ||
import Config | ||
|
||
config :live_view_native, plugins: [ | ||
LiveViewNative.HTML | ||
] | ||
|
||
# config :phoenix_template, format_encoders: [ | ||
# html: Phoenix.HTML.Engine | ||
# ] | ||
|
||
# config :phoenix, template_engines: [ | ||
# heex: LiveViewNative.Engine | ||
# ] | ||
|
||
config :live_view_native_test, | ||
formats: [:html], | ||
otp_app: :live_view_native_html, | ||
routes: [ | ||
%{path: "/inline", module: LiveViewNativeTest.HTML.InlineLive}, | ||
%{path: "/template", module: LiveViewNativeTest.HTML.TemplateLive} | ||
] | ||
|
||
config :phoenix, :plug_init_mode, :runtime |
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 was deleted.
Oops, something went wrong.
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,27 @@ | ||
defmodule LiveViewNative.HTML.InlineRenderTest do | ||
use ExUnit.Case, async: false | ||
|
||
import Phoenix.ConnTest | ||
import Plug.Conn, only: [put_req_header: 3] | ||
import Phoenix.LiveViewTest | ||
|
||
@endpoint LiveViewNativeTest.Endpoint | ||
|
||
setup do | ||
{:ok, conn: Plug.Test.init_test_session(build_conn(), %{})} | ||
end | ||
|
||
test "can render the override html format", %{conn: conn} do | ||
conn = put_req_header(conn, "accept", "text/html") | ||
{:ok, lv, _html} = live(conn, "/inline") | ||
|
||
assert lv |> element("#override-container #inline") |> render() =~ "Inline HTML Override Render 100" | ||
end | ||
|
||
test "can render the override html format with mobile target", %{conn: conn} do | ||
conn = put_req_header(conn, "accept", "text/html") | ||
{:ok, lv, _html} = live(conn, "/inline?target=mobile") | ||
|
||
assert lv |> element("#mobile-inline") |> render() =~ "Mobile Target Inline HTML Override Render 100" | ||
end | ||
end |
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,27 @@ | ||
defmodule LiveViewNative.HTML.TemplateRenderTest do | ||
use ExUnit.Case, async: false | ||
|
||
import Phoenix.ConnTest | ||
import Plug.Conn, only: [put_req_header: 3] | ||
import Phoenix.LiveViewTest | ||
|
||
@endpoint LiveViewNativeTest.Endpoint | ||
|
||
setup do | ||
{:ok, conn: Plug.Test.init_test_session(build_conn(), %{})} | ||
end | ||
|
||
test "can render the override html format", %{conn: conn} do | ||
conn = put_req_header(conn, "accept", "text/html") | ||
{:ok, lv, _html} = live(conn, "/template") | ||
|
||
assert lv |> element("#override-container #template") |> render() =~ "Template HTML Override Render 100" | ||
end | ||
|
||
test "can render the override html format with mobile target", %{conn: conn} do | ||
conn = put_req_header(conn, "accept", "text/html") | ||
{:ok, lv, _html} = live(conn, "/template?target=mobile") | ||
|
||
assert lv |> element("#mobile-template") |> render() =~ "Mobile Target Template HTML Override Render 100" | ||
end | ||
end |
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,8 @@ | ||
defmodule LiveViewNativeTest.HTML.Layouts do | ||
use Phoenix.Component | ||
|
||
import Phoenix.Controller, | ||
only: [get_csrf_token: 0] | ||
|
||
embed_templates "layouts/*" | ||
end |
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 @@ | ||
<div id="html-container"><%= @inner_content %></div> |
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 @@ | ||
<div id="override-container"><%= @inner_content %></div> |
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,2 @@ | ||
<meta name="csrf-token" content={get_csrf_token()} /> | ||
<%= @inner_content %> |
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 @@ | ||
<div id="mobile-template">Mobile Target Template HTML Override Render <%= @count %></div> |
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 @@ | ||
<div id="template">Template HTML Override Render <%= @count %></div> |
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,34 @@ | ||
defmodule LiveViewNativeTest.HTML.InlineLive.HTML do | ||
use LiveViewNative.Component, | ||
format: :html, | ||
as: :render | ||
|
||
def render(assigns, %{target: "mobile"}) do | ||
~H""" | ||
<div id="mobile-inline">Mobile Target Inline HTML Override Render <%= @count %></div> | ||
""" | ||
end | ||
|
||
def render(assigns, _interface) do | ||
~H""" | ||
<div id="inline">Inline HTML Override Render <%= @count %></div> | ||
""" | ||
end | ||
end | ||
|
||
defmodule LiveViewNativeTest.HTML.InlineLive do | ||
use Phoenix.LiveView, | ||
layout: {LiveViewNativeTest.HTML.Layouts, :app} | ||
|
||
use LiveViewNative.LiveView, | ||
formats: [:html], | ||
layouts: [ | ||
html: {LiveViewNativeTest.HTML.Layouts, :override} | ||
] | ||
|
||
def mount(_params, _session, socket) do | ||
{:ok, assign(socket, :count, 100)} | ||
end | ||
|
||
def render(assigns), do: ~H"" | ||
end |
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,22 @@ | ||
defmodule LiveViewNativeTest.HTML.TemplateLive.HTML do | ||
use LiveViewNative.Component, | ||
format: :html, | ||
as: :render | ||
end | ||
|
||
defmodule LiveViewNativeTest.HTML.TemplateLive do | ||
use Phoenix.LiveView, | ||
layout: {LiveViewNativeTest.HTML.Layouts, :app} | ||
|
||
use LiveViewNative.LiveView, | ||
formats: [:html], | ||
layouts: [ | ||
html: {LiveViewNativeTest.HTML.Layouts, :override} | ||
] | ||
|
||
def mount(_params, _session, socket) do | ||
{:ok, assign(socket, :count, 100)} | ||
end | ||
|
||
def render(assigns), do: ~H"" | ||
end |
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
{:ok, _} = LiveViewNativeTest.Endpoint.start_link() | ||
|
||
ExUnit.start() |