Skip to content

Commit 5f289f1

Browse files
authored
Merge branch 'master' into dependabot-hex-ex_doc-0.27.3
2 parents b4b8448 + 8d7ab99 commit 5f289f1

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ def view() do
7575
end
7676
```
7777

78+
### JSON library selection
79+
80+
ExCSSModules needs to parse JSON files in order to read the mappings between the base classe names and the autogenerated
81+
ones. You can specify which JSON parsing library you wish to use through the `:json_library` config option. If your
82+
project uses Phoenix, it is recommended to use the same library for both Phoenix and ExCSSModules. ExCSSModules uses
83+
[Poison](https://hex.pm/packages/poison) by default.
84+
7885
### ExCell
7986
ExCSSModules works perfectly with [ExCell](https://github.com/DefactoSoftware/ex_cell). By adding the following to your `web.ex` definition for cells you can automatically add the stylesheet in the same directory as your ExCell Cell:
8087
```ex

lib/ex_css_modules/ex_css_modules.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ defmodule ExCSSModules do
4040
true ->
4141
(filename <> ".json")
4242
|> File.read!()
43-
|> Poison.decode!()
43+
|> json_library().decode!()
4444

4545
false ->
4646
%{}
@@ -209,4 +209,6 @@ defmodule ExCSSModules do
209209

210210
defp join_class_name([_ | _] = list), do: Enum.join(list, " ")
211211
defp join_class_name([]), do: nil
212+
213+
defp json_library, do: Application.get_env(:ex_css_modules, :json_library, Poison)
212214
end

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ defmodule ExCSSModules.Mixfile do
5050
{:excoveralls, "~> 0.14.4", only: :test},
5151
{:dialyxir, "~> 1.1", only: [:dev, :test], runtime: false},
5252
{:phoenix_html, "~> 1.0 or ~> 2.0 or ~> 3.0"},
53-
{:poison, "~> 4.0 or ~> 5.0"},
53+
{:poison, "~> 4.0 or ~> 5.0", optional: true},
5454
{:mix_test_watch, "~> 1.1", only: :dev, runtime: false},
5555
{:credo, "~> 1.6", only: [:dev, :test], runtime: false}
5656
]

0 commit comments

Comments
 (0)