cv_gen.ex 578 B

12345678910111213141516171819202122
  1. defmodule CvGen do
  2. @moduledoc """
  3. Documentation for `CvGen`.
  4. """
  5. @template_file "lib/templates/cv.html.heex"
  6. @data_file "priv/data/cv.json"
  7. @output_file "priv/output/cv.html"
  8. def generate do
  9. with raw_data <- File.read!(@data_file),
  10. {:ok, assigns} <- Jason.decode(raw_data, keys: :atoms),
  11. res <- CvGenView.cv(assigns) |> Phoenix.HTML.Safe.to_iodata() |> List.to_string(),
  12. do: File.write!(@output_file, res)
  13. end
  14. def paths(),
  15. do: %{
  16. template: @template_file,
  17. data: @data_file,
  18. output: @output_file
  19. }
  20. end