cv_gen.ex 471 B

123456789101112131415
  1. defmodule CvGen do
  2. @moduledoc """
  3. Documentation for `CvGen`.
  4. """
  5. @template_file "lib/templates/cv.html.eex"
  6. @data_file "lib/templates/cv.json"
  7. @output_file "lib/templates/output.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. end