Skip to content

Commit 26101fa

Browse files
author
Peter Arentsen
committed
Update liquid for elixir 1.4 compatibility and update depencies also for reducing warnings
1 parent 3c4ab5f commit 26101fa

File tree

12 files changed

+48
-48
lines changed

12 files changed

+48
-48
lines changed

lib/liquid.ex

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Liquid do
22
use Application
33

4-
def start(_type, _args), do: start
4+
def start(_type, _args), do: start()
55

66
def start do
77
Liquid.Filters.add_filter_modules
@@ -10,10 +10,10 @@ defmodule Liquid do
1010

1111
def stop, do: {:ok, "stopped"}
1212

13-
def filter_arguments, do: ~r/(?::|,)\s*(#{quoted_fragment})/
13+
def filter_arguments, do: ~r/(?::|,)\s*(#{quoted_fragment()})/
1414
def single_quote, do: "'"
1515
def double_quote, do: "\""
16-
def quote_matcher, do: ~r/#{single_quote}|#{double_quote}/
16+
def quote_matcher, do: ~r/#{single_quote()}|#{double_quote()}/
1717

1818
def variable_start, do: "{{"
1919
def variable_end, do: "}}"
@@ -24,17 +24,17 @@ defmodule Liquid do
2424

2525
def any_starting_tag, do: "(){{()|(){%()"
2626

27-
def tokenizer, do: ~r/()#{tag_start}.*?#{tag_end}()|()#{variable_start}.*?#{variable_end}()/
28-
def parser, do: ~r/#{tag_start}\s*(?<tag>.*?)\s*#{tag_end}|#{variable_start}\s*(?<variable>.*?)\s*#{variable_end}/m
29-
def template_parser, do: ~r/#{partial_template_parser}|#{any_starting_tag}/ms
30-
def partial_template_parser, do: "()#{tag_start}.*?#{tag_end}()|()#{variable_start}.*?#{variable_incomplete_end}()"
27+
def tokenizer, do: ~r/()#{tag_start()}.*?#{tag_end()}()|()#{variable_start()}.*?#{variable_end()}()/
28+
def parser, do: ~r/#{tag_start()}\s*(?<tag>.*?)\s*#{tag_end()}|#{variable_start()}\s*(?<variable>.*?)\s*#{variable_end()}/m
29+
def template_parser, do: ~r/#{partial_template_parser()}|#{any_starting_tag()}/ms
30+
def partial_template_parser, do: "()#{tag_start()}.*?#{tag_end()}()|()#{variable_start()}.*?#{variable_incomplete_end()}()"
3131

3232
def quoted_string, do: "\"[^\"]*\"|'[^']*'"
33-
def quoted_fragment, do: "#{quoted_string}|(?:[^\s,\|'\"]|#{quoted_string})+"
33+
def quoted_fragment, do: "#{quoted_string()}|(?:[^\s,\|'\"]|#{quoted_string()})+"
3434

35-
def tag_attributes, do: ~r/(\w+)\s*\:\s*(#{quoted_fragment})/
35+
def tag_attributes, do: ~r/(\w+)\s*\:\s*(#{quoted_fragment()})/
3636
def variable_parser, do: ~r/\[[^\]]+\]|[\w\-]+/
37-
def filter_parser, do: ~r/(?:\||(?:\s*(?!(?:\|))(?:#{quoted_fragment}|\S+)\s*)+)/
37+
def filter_parser, do: ~r/(?:\||(?:\s*(?!(?:\|))(?:#{quoted_fragment()}|\S+)\s*)+)/
3838

3939
defmodule List do
4040
def even_elements([_,h|t]) do

lib/liquid/appointer.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ defmodule Liquid.Appointer do
2727
@spec parse_name(String.t) :: String.t
2828
def parse_name(name) do
2929
value = cond do
30-
literals |> Map.has_key?(name) ->
31-
literals |> Map.get(name)
32-
integer |> Regex.match?(name) ->
30+
literals() |> Map.has_key?(name) ->
31+
literals() |> Map.get(name)
32+
integer() |> Regex.match?(name) ->
3333
name |> String.to_integer
34-
float |> Regex.match?(name) ->
34+
float() |> Regex.match?(name) ->
3535
name |> String.to_float
36-
start_quoted_string |> Regex.match?(name) ->
36+
start_quoted_string() |> Regex.match?(name) ->
3737
Liquid.quote_matcher |> Regex.replace(name, "")
3838
true ->
3939
Liquid.variable_parser |> Regex.scan(name) |> List.flatten

lib/liquid/file_system.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ defmodule Liquid.FileSystem do
3535
Get full file system path
3636
"""
3737
def full_path(path) do
38-
case lookup do
38+
case lookup() do
3939
nil -> { :error, "No file system defined" }
4040
{ mod, root } -> mod.full_path(root, path)
4141
end
4242
end
4343

4444
def read_template_file(path, options \\ []) do
45-
case lookup do
45+
case lookup() do
4646
nil -> { :error, "No file system defined" }
4747
{ mod, root } -> mod.read_template_file(root, path, options)
4848
end

lib/liquid/include.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ defmodule Liquid.Include do
88
def syntax, do: ~r/(#{Liquid.quoted_fragment}+)(\s+(?:with|for)\s+(#{Liquid.quoted_fragment}+))?/
99

1010
def parse(%Tag{markup: markup}=tag, %Template{}=template) do
11-
[parts|_] = syntax |> Regex.scan(markup)
11+
[parts|_] = syntax() |> Regex.scan(markup)
1212
tag = parse_tag(tag, parts)
1313
attributes = parse_attributes(markup)
1414
{ %{tag | attributes: attributes }, template }

lib/liquid/registers.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ defmodule Liquid.Registers do
2626
end
2727

2828
def clear do
29-
Application.put_env(:liquid, :extra_tags, default_tags)
29+
Application.put_env(:liquid, :extra_tags, default_tags())
3030
end
3131

3232
def lookup(name) when is_binary(name) do
@@ -35,15 +35,15 @@ defmodule Liquid.Registers do
3535

3636
def lookup(name) when is_atom(name) do
3737
custom_tags = Application.get_env(:liquid, :extra_tags)
38-
case {name, default_tags[name], custom_tags[name]} do
38+
case {name, default_tags()[name], custom_tags[name]} do
3939
{nil, _, _} -> nil
4040
{_, nil, nil} -> nil
4141
{_, nil, custom_tag} -> custom_tag
4242
{_, tag, _} -> tag
4343
end
4444
end
4545

46-
def lookup(_), do: nil
46+
def lookup(_), do: nil
4747

4848
def register(name, module, type) do
4949
custom_tags = Application.get_env(:liquid, :extra_tags) || %{}

lib/liquid/tags/assign.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ defmodule Liquid.Assign do
88
def parse(%Tag{}=tag, %Liquid.Template{}=template), do: { %{tag | blank: true }, template }
99

1010
def render(output, %Tag{markup: markup}, %Context{}=context) do
11-
[[_, to, from]] = syntax |> Regex.scan(markup)
11+
[[_, to, from]] = syntax() |> Regex.scan(markup)
1212
from_value = from |> Variable.create
1313
|> Variable.lookup(context)
1414
result_assign = context.assigns |> Map.put(to, from_value)

lib/liquid/tags/case.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defmodule Liquid.Case do
1111

1212

1313
def parse(%Block{markup: markup}=b, %Template{}=t) do
14-
[[_, name]] = syntax |> Regex.scan(markup)
14+
[[_, name]] = syntax() |> Regex.scan(markup)
1515
{ split(name |> Variable.create, b.nodelist), t }
1616
end
1717

@@ -39,7 +39,7 @@ defmodule Liquid.Case do
3939

4040

4141
defp parse_when(markup) do
42-
[[_,h|t]|m] = when_syntax |> Regex.scan(markup)
42+
[[_,h|t]|m] = when_syntax() |> Regex.scan(markup)
4343
m = m |> List.flatten |> Liquid.List.even_elements
4444
t = [t|m] |> Enum.join(" ")
4545
t = if t == "", do: [], else: [t]

lib/liquid/tags/for_else.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ defmodule Liquid.ForElse do
7171
end
7272

7373
defp parse_iterator(%Block{markup: markup}) do
74-
[[_,item|[orig_collection|reversed]]] = Regex.scan(syntax, markup)
74+
[[_,item|[orig_collection|reversed]]] = Regex.scan(syntax(), markup)
7575
collection = Expression.parse(orig_collection)
7676
reversed = !(reversed |> List.first |> is_nil)
7777
attributes = Liquid.tag_attributes |> Regex.scan(markup)

lib/liquid/tags/if_else.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ defmodule Liquid.IfElse do
5252

5353
defp split_conditions(expressions) do
5454
expressions |> List.flatten |> Enum.map(&String.strip/1) |> Enum.map(fn(x) ->
55-
case syntax |> Regex.scan(x) do
55+
case syntax() |> Regex.scan(x) do
5656
[[_, left, operator, right]] -> { left, operator, right }
5757
[[_, x]] -> x
5858
end
5959
end)
6060
end
6161

6262
defp parse_conditions(%Block{markup: markup}=block) do
63-
expressions = Regex.scan(expressions_and_operators, markup)
63+
expressions = Regex.scan(expressions_and_operators(), markup)
6464
expressions = expressions |> split_conditions |> Enum.reverse
6565
condition = Condition.create(expressions)
6666
%{block | condition: condition }

lib/liquid/tags/table_row.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ defmodule Liquid.TableRow do
3636

3737

3838
defp parse_iterator(%Block{markup: markup}) do
39-
[[_,item|[orig_collection]]] = Regex.scan(syntax, markup)
39+
[[_,item|[orig_collection]]] = Regex.scan(syntax(), markup)
4040
collection = Expression.parse(orig_collection)
4141
attributes = Liquid.tag_attributes |> Regex.scan(markup)
4242
limit = attributes |> parse_attribute("limit") |> Variable.create
@@ -195,4 +195,4 @@ defmodule Liquid.TableRow do
195195
defp get_loop_indexes(loop, _cols, _offset),
196196
do: {loop["col"], false, loop["row"]}
197197

198-
end
198+
end

0 commit comments

Comments
 (0)