Skip to content

Instantly share code, notes, and snippets.

@khusnetdinov
Last active December 11, 2016 17:51
Show Gist options
  • Save khusnetdinov/0e2eada270fee80640be8cf32a50ba37 to your computer and use it in GitHub Desktop.
Save khusnetdinov/0e2eada270fee80640be8cf32a50ba37 to your computer and use it in GitHub Desktop.
Phoenix embed templates
# Embed all defined templates
root = Path.expand("../templates", __DIR__)
for {format, source, _} <- @new ++ @ecto ++ @brunch ++ @html ++ @static ++ @bare do
unless format == :keep do
@external_resource Path.join(root, source)
def render(unquote(source)), do: unquote(File.read!(Path.join(root, source)))
end
end
# Embed missing files from Phoenix static.
embed_text :phoenix_js, from_file: Path.expand("../../priv/static/phoenix.js", __DIR__)
embed_text :phoenix_png, from_file: Path.expand("../../priv/static/phoenix.png", __DIR__)
embed_text :phoenix_favicon, from_file: Path.expand("../../priv/static/favicon.ico", __DIR__)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment