File tree Expand file tree Collapse file tree 2 files changed +18
-12
lines changed
lib/components_guide/wasm/examples/podcast_feed Expand file tree Collapse file tree 2 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -102,24 +102,24 @@ defmodule ComponentsGuide.Wasm.PodcastFeed do
102102 loop Episodes do
103103 _ =
104104 build! do
105- XML . build :item do
106- XML . build :guid , isPermaLink: "false" do
105+ XML . element :item do
106+ XML . element :guid , isPermaLink: "false" do
107107 write_episode_data ( :id , episode_index )
108108 end
109109
110- XML . build :title do
110+ XML . element :title do
111111 write_episode_data ( :title , episode_index )
112112 end
113113
114- XML . build :"itunes:title" do
114+ XML . element :"itunes:title" do
115115 write_episode_data ( :title , episode_index )
116116 end
117117
118- XML . build :description do
118+ XML . element :description do
119119 write_episode_data ( :description , episode_index )
120120 end
121121
122- XML . build :"itunes:subtitle" do
122+ XML . element :"itunes:subtitle" do
123123 write_episode_data ( :description , episode_index )
124124 end
125125 end
Original file line number Diff line number Diff line change @@ -42,11 +42,6 @@ defmodule ComponentsGuide.Wasm.PodcastFeed.XMLFormatter do
4242 end
4343 end
4444
45- def element ( tag , child ) when is_atom ( tag ) do
46- tag = Orb.DSL . const ( Atom . to_string ( tag ) )
47- xml_element ( tag , child )
48- end
49-
5045 defwi xml_element ( tag: I32.String , child: I32.String ) , I32.String do
5146 build! do
5247 # "<" <> tag <> ">"
@@ -88,7 +83,9 @@ defmodule ComponentsGuide.Wasm.PodcastFeed.XMLFormatter do
8883 end
8984 end
9085
91- defmacro build ( tag , attributes \\ [ ] , do: block ) do
86+ defmacro element ( tag , attributes \\ [ ] , content )
87+
88+ defmacro element ( tag , attributes , do: block ) do
9289 quote do
9390 [
9491 BuildToken . start ( ) ,
@@ -116,6 +113,15 @@ defmodule ComponentsGuide.Wasm.PodcastFeed.XMLFormatter do
116113 end
117114 end
118115
116+ defmacro element ( tag , _attributes , content ) do
117+ quote do
118+ unquote ( __MODULE__ ) . xml_element (
119+ Orb.DSL . const ( Atom . to_string ( unquote ( tag ) ) ) ,
120+ unquote ( content )
121+ )
122+ end
123+ end
124+
119125 defmacro __using__ ( as: some_alias ) do
120126 quote do
121127 require unquote ( __MODULE__ ) , as: unquote ( some_alias )
You can’t perform that action at this time.
0 commit comments