exfile v0.3.6 Exfile.Phoenix.Helpers View Source

View helpers to use Exfile in your Phoenix app.

To use these helpers, import it in the view section of your web/web.ex file.

defmodule MyApp.Web do
  def view do
    quote do
      use Phoenix.View, root: "web/templates"
      ...
      import Exfile.Phoenix.Helpers
    end
  end
end

Link to this section Summary

Functions

Returns the absolute path of a file with the options passed

Returns the absolute URL of a file with the options passed

Link to this section Types

Link to this type exfile_path_opts() View Source
exfile_path_opts() :: [processor: String.t, processor_args: [String.t], format: String.t, filename: String.t]

Link to this section Functions

Link to this function exfile_path(file, opts \\ []) View Source

Returns the absolute path of a file with the options passed.

Valid options:

  • processor: Specify a processor to run before outputing the file (string).
  • processor_args: Specify a list of arguments to pass to the processor. Requires processor to be set.
  • format: Specify the format of the file
  • filename: Customize the filename (default is file.[format] or file if format is not specified). Note that this will override anything that is set in format.

Returns the absolute URL of a file with the options passed.

See exfile_path/2 for valid options.

The first argument accepts any parameter that the Phoenix generated _url function takes. If cdn_host is configured for Exfile, this first argument is not necessary.