Skip to content

Commit 45995b3

Browse files
Merge pull request #7 from DefactoSoftware/jesse/expand-embed-option
Expand embed option to allow evaluated code
2 parents c323769 + ac8d92d commit 45995b3

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/ex_css_modules/view.ex

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,20 @@ defmodule ExCSSModules.View do
1818
"""
1919

2020
defmacro __using__(opts \\ []) do
21-
{file, [file: relative_to]} =
21+
{filename, [file: relative_to]} =
2222
Code.eval_quoted(opts[:stylesheet], file: __CALLER__.file)
2323

24-
file = Path.expand(file, Path.dirname(relative_to))
24+
{embed, _} =
25+
Code.eval_quoted(opts[:embed_stylesheet])
26+
27+
filename = Path.expand(filename, Path.dirname(relative_to))
2528

2629
quote do
2730
@stylesheet unquote(
28-
if opts[:embed_stylesheet] do
29-
Macro.escape(ExCSSModules.read_stylesheet(file))
31+
if embed do
32+
Macro.escape(ExCSSModules.read_stylesheet(filename))
3033
else
31-
Macro.escape(file)
34+
Macro.escape(filename)
3235
end
3336
)
3437

0 commit comments

Comments
 (0)