~mika/www.m1kadev.nl

ref: 4d656d6d3c0d08b651351dd9aa938794e7a481b6 www.m1kadev.nl/kethel/lib/bricks.ex -rw-r--r-- 626 bytes
4d656d6d — m1kadev Start refactoring build.exs into kethel 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
defmodule Bricks do
  @typedoc "A path, relative to mix.exs"
  @type relative_path() :: String.t()

  @typedoc "The name of the brick"
  @type brick_name() :: String.t()

  @typedoc "A valid mustache template"
  @type mustache() :: String.t()

  @spec collect(relative_path()) :: %{brick_name() => mustache()}
  def collect(folder) do
    Path.wildcard(folder <> "/bricks/*.thtml")
      |> Enum.map(fn brick -> { brick, File.read!(brick) } end) 
      |> Enum.map(fn { brick, contents } -> { Path.basename(brick) |> Path.rootname(), contents } end) # "../bricks/base_header.html" would beccome just "base_header"
  end
 end