Skip to content

Instantly share code, notes, and snippets.

@matheusca
Last active December 28, 2015 03:48
Show Gist options
  • Save matheusca/7437435 to your computer and use it in GitHub Desktop.
Save matheusca/7437435 to your computer and use it in GitHub Desktop.
defmodule Weber.Controller do
defmacro __using__(_) do
quote do
@before_compile { unquote(__MODULE__), :purge_files}
import Weber.Controller.Layout
layout('main.html')
end
end
defmacro purge_files(_) do
{ :ok, root } = File.cwd
if System.get_env("MIX_ENV") != "prod" do
Weber.Reload.start_link(root)
Weber.Reload.enable
if Code.ensure_loaded?(IEx) and IEx.started? do
IEx.after_spawn(fn -> Weber.Reload.enable end)
end
Weber.Reload.purge
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment