Skip to content

Commit

Permalink
Fixed warnings in Elixir 1.4.0 (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
lasseebert authored and doomspork committed Jan 10, 2017
1 parent 462c737 commit 516cca5
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/slime.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule Slime do
Sample.sample(1, 2) #=> "3"
"""
defmacro function_from_file(kind, name, file, args \\ [], opts \\ []) do
quote bind_quoted: binding do
quote bind_quoted: binding() do
require EEx
eex = file |> File.read! |> Renderer.precompile
EEx.function_from_string(kind, name, eex, args, opts)
Expand All @@ -59,7 +59,7 @@ defmodule Slime do
"3"
"""
defmacro function_from_string(kind, name, source, args \\ [], opts \\ []) do
quote bind_quoted: binding do
quote bind_quoted: binding() do
require EEx
eex = source |> Renderer.precompile
EEx.function_from_string(kind, name, eex, args, opts)
Expand Down
3 changes: 0 additions & 3 deletions lib/slime/doctype.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@ defmodule Slime.Doctype do
def for("basic"),
do: ~S[<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">]

@lint false
def for("frameset"),
do: ~S[<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">]

@lint false
def for("mobile"),
do: ~S[<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">]

def for("strict"),
do: ~S[<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">]

@lint false
def for("transitional"),
do: ~S[<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">]

Expand Down
9 changes: 4 additions & 5 deletions lib/slime/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defmodule Slime.Parser do
@attr_group_regex ~r/(?:\s*[\w-]+\s*=\s*(?:[^"'].*?(?= [^ "']+=|$)|"(?:(?<z>\{(?:[^{}]|\g<z>)*\})|[^"])*"|'[^']*'))*/

@parse_line_split_regexes @attr_list_delims
|> Dict.keys
|> Map.keys
|> Enum.map(&("|\\" <> &1))
@parse_line_split_regexes ["\\s|="] ++ @parse_line_split_regexes
@parse_line_split_regex @parse_line_split_regexes
Expand All @@ -34,7 +34,6 @@ defmodule Slime.Parser do
@eex_line_regex ~r/^(\s*)(-|=|==)\s*(.*?)$/

@merge_attrs %{class: " "}
@indent 2

def parse_lines(lines, acc \\ [])

Expand Down Expand Up @@ -142,7 +141,7 @@ defmodule Slime.Parser do

defp parse_attributes(line) do
delim = String.first(line)
if Dict.has_key?(@attr_list_delims , delim) do
if Map.has_key?(@attr_list_delims , delim) do
line = String.slice(line, 1..-1)
parse_wrapped_attributes(line, @attr_list_delims[delim])
else
Expand Down Expand Up @@ -236,8 +235,8 @@ defmodule Slime.Parser do
end

spaces = %{}
spaces = if parts["leading_space"] != "", do: Dict.put(spaces, :leading, true), else: spaces
spaces = if parts["trailing_space"] != "", do: Dict.put(spaces, :trailing, true), else: spaces
spaces = if parts["leading_space"] != "", do: Map.put(spaces, :leading, true), else: spaces
spaces = if parts["trailing_space"] != "", do: Map.put(spaces, :trailing, true), else: spaces

case Regex.named_captures(@id_regex, parts["css"]) do
nil ->
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defmodule Slime.Mixfile do
def project do
[app: :slime,
build_embedded: Mix.env == :prod,
deps: deps,
deps: deps(),
description: """
An Elixir library for rendering Slim-like templates.
""",
Expand Down
2 changes: 1 addition & 1 deletion test/rendering/attributes_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ defmodule RenderAttributesTest do
Slime.function_from_string(:def, :pre_render, @slime, [], engine: Phoenix.HTML.Engine)

def render do
pre_render |> Phoenix.HTML.Safe.to_iodata |> IO.iodata_to_binary
pre_render() |> Phoenix.HTML.Safe.to_iodata |> IO.iodata_to_binary
end
end

Expand Down

0 comments on commit 516cca5

Please sign in to comment.