Skip to content

Commit 6fbaa8e

Browse files
committed
Add use + var info to readme. Closes #65
1 parent 405f299 commit 6fbaa8e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,13 @@ For example, given the following broken code after an initial `mix format`:
152152
```elixir
153153
defmodule MyGreatLibrary do
154154
@moduledoc make_pretty_docs(@library_options)
155+
use OptionsMagic, my_opts: @library_options
155156

156157
@library_options [ ... ]
157158
end
158159
```
159160

160-
You can fix the code by moving the static value outside of the module into a naked variable and then reference it in the module.
161+
You can fix the code by moving the static value outside of the module into a naked variable and then reference it in the module. (Note that `use` macros need an `unquote` wrapping the variable!)
161162

162163
Yes, this is a thing you can do in a `.ex` file =)
163164

@@ -166,6 +167,7 @@ library_options = [ ... ]
166167

167168
defmodule MyGreatLibrary do
168169
@moduledoc make_pretty_docs(library_options)
170+
use OptionsMagic, my_opts: unquote(library_options)
169171

170172
@library_options library_options
171173
end

0 commit comments

Comments
 (0)