~mika/www.m1kadev.nl

ref: 1c5e50a88b88ab1d2e500cdec0ab3257da2dce11 www.m1kadev.nl/kethel/lib/bricks.ex -rw-r--r-- 613 bytes
1c5e50a8 — m1kadev kethel: start stage 1 of build api: collect 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() :: binary()

  @typedoc "The name of the brick"
  @type brick_name() :: binary()

  @typedoc "A valid mustache template"
  @type mustache() :: binary()

  @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 } -> { FileX.trimmed_filename(brick), contents } end) # "../bricks/base_header.html" would beccome just "base_header"
  end
 end