Packages

An Elixir wrapper for various Erlang gen modules

Retired package: Security issue - Blown away. Started over w/ v0.2.0

Current section

Files

Jump to
gin lib mix tasks compile.gin.templates.ex
Raw

lib/mix/tasks/compile.gin.templates.ex

defmodule Mix.Tasks.Compile.Gin.Templates do
use Mix.Task
defstruct [:source]
#######
# API #
#######
def run(_) do
Enum.map(Mix.Project.config[:"gin.templates"], &compile/1)
end
###########
# Private #
###########
defp compile({source,data}) do
target = String.trim_trailing(source, ".eex")
head = head(source)
body = EEx.eval_file(source, data)
content = head <> body
File.write(target, content)
end
defp head(source) do
"""
*Note: Do not edit this file; it's autogenerated. Instead, edit [#{source}](#{source}).*
"""
end
end