Current section

34 Versions

Jump to

Compare versions

6 files changed
+109 additions
-6 deletions
  @@ -4,6 +4,104 @@
4 4
5 5 Nothing Yet
6 6
7 + ## 0.6.0 The LiveView compatibility release!
8 +
9 + Temple now is written to be fully compatible with Phoenix LiveView! This comes with substantial internal changes as well as a better component API.
10 +
11 + ### Phoenix LiveView
12 +
13 + Temple now outputs LiveView compatible EEx at compile time, which is fed right into the normal LiveView EEx engine (or the traditional HTML Engine if you are not using LiveView).
14 +
15 + ### Components
16 +
17 + Temple now has a more complete component API.
18 +
19 + Components work with anywhere, whether you are writing a little plug app, a vanilla Phoenix app, or a Phoenix LiveView app!
20 +
21 + Please see the [documenation](https://hexdocs.pm/temple/Temple.html) for more information.
22 +
23 + To migrate component from the 0.5.0 syntax to the 0.6.0 syntax, you can use the following as a guide
24 +
25 + ```elixir
26 + # 0.5.0
27 +
28 + # definition
29 + defmodule PageView do
30 + defcomponent :flex do
31 + div id: @id, class: "flex" do
32 + @children
33 + end
34 + end
35 + end
36 +
37 + # usage
38 +
39 + require PageView
40 + # or
41 +
42 + import PageView
43 +
44 + temple do
45 + PageView.flex id: "my-flex" do
46 + div "Item 1"
47 + div "Item 2"
48 + div "Item 3"
49 + end
50 +
51 + # with import
52 + flex id: "my-flex" do
53 + div "Item 1"
54 + div "Item 2"
55 + div "Item 3"
56 + end
57 + end
58 + ```
59 +
60 + to
61 +
62 + ```elixir
63 + # 0.6.0
64 +
65 + # definition
66 +
67 + defmodule Flex do
68 + import Temple.Component
69 +
70 + render do
71 + div id: @id, class: "flex" do
72 + slot :default
73 + end
74 + end
75 + end
76 +
77 + # usage
78 +
79 + temple do
80 + c Flex id: "my-flex" do
81 + div do: "Item 1"
82 + div do: "Item 2"
83 + div do: "Item 3"
84 + end
85 + end
86 + ```
87 +
88 + ### Other breaking changes
89 +
90 + 0.6.0 has been a year in the making and a lot has changed in that time (in many cases, several times over), and I honestly can't really remember everything that is different now, but I will list some things here that I think you'll need to change or look out for.
91 +
92 + - The `partial` macro is removed.
93 + - You can now just call the `render` function like you normally would to render a phoenix partial.
94 + - The `defcomponent` macro is removed.
95 + - You now define components using the API described above.
96 + - The `text` macro is now removed.
97 + - You can just use a string literal or a variable to emit a text node.
98 + - Elements and components no longer can take "content" as the first argument. A do block is now required, but you can still use the keyword list style for a concise style, e.g., `span do: "foobar"` instead of `span "foobar"`.
99 + - The `:compact` reserved keyword option was removed.
100 + - The macros that wrapped `Phoenix.HTML` are removed as they are no longer needed.
101 + - The `temple.convert` task has been removed, but I am working to bring it back.
102 +
103 + There might be some more, so if you run into any problems, please open a [GitHub Discussion](https://github.com/mhanberg/temple/discussions/new).
104 +
7 105 ## 0.6.0-rc.1
8 106
9 107 ### Enhancements
  @@ -16,9 +16,9 @@ Add `temple` to your list of dependencies in `mix.exs`:
16 16 ```elixir
17 17 def deps do
18 18 [
19 - {:temple, "~> 0.6.0-rc.0"},
19 + {:temple, "~> 0.6.0-rc.1"},
20 20 {:phoenix, ">= 1.5.0"}, # requires at least Phoenix v1.5.0
21 - {:phoenix_live_ivew, github: "phoenixframework/phoenix_live_ivew"} # currently requires an unreleased version of phoenix_live_ivew if you are using live view
21 + {:phoenix_live_view, github: "phoenixframework/phoenix_live_view"} # currently requires an unreleased version of phoenix_live_view if you are using live view
22 22 ]
23 23 end
24 24 ```
  @@ -140,6 +140,9 @@ config :phoenix, :template_engines,
140 140 # you can enable Elixir syntax highlighting in your editor
141 141 lexs: Temple.LiveViewEngine
142 142
143 + # If you're going to be using live_view, make sure to set the `:mode`
144 + config :temple, :mode, :live_view # defaults to normal
145 +
143 146 # config/dev.exs
144 147 config :your_app, YourAppWeb.Endpoint,
145 148 live_reload: [
  @@ -54,4 +54,4 @@
54 54 {<<"optional">>,true},
55 55 {<<"repository">>,<<"hexpm">>},
56 56 {<<"requirement">>,<<">= 0.0.0">>}]]}.
57 - {<<"version">>,<<"0.6.0-rc.1">>}.
57 + {<<"version">>,<<"0.6.0">>}.
  @@ -104,6 +104,7 @@ defmodule Temple do
104 104 defmacro __using__(_) do
105 105 quote location: :keep do
106 106 import Temple
107 + require Temple.Component
107 108 end
108 109 end
  @@ -6,6 +6,8 @@ defmodule Temple.Component do
6 6
7 7 Since component modules are view modules, the assigns you pass to the component are accessible via the `@` macro and the `assigns` variable.
8 8
9 + You must `require Temple.Component` in your views that use components, as the `c` and `slot` generate markup that uses macros provided by Temple.
10 +
9 11 ## Components
10 12
11 13 ```elixir
Loading more files…