resx v0.0.2 Resx.Resource.Content

The content of a resource.

%Resx.Resource.Content{
    type: ["text/html]",
    data: "<p>Hello</p>"
}

Link to this section Summary

Functions

Retrieve the content data

Make some content explicit

Get the binary reducer for this content

Link to this section Types

Link to this type acc()
acc() :: any()
Link to this type mime()
mime() :: String.t()
Link to this type reducer()
reducer() :: (acc(), (binary(), acc() -> acc()) -> acc())
Link to this type t()
t() :: %Resx.Resource.Content{data: any(), type: type()}
Link to this type type()
type() :: [mime(), ...]

Link to this section Functions

Retrieve the content data.

Make some content explicit.

Get the binary reducer for this content.

Returns a function that will reduce the content into its binary form.

By default this returns a reducer that assumes content is already in its binary form. But this can be overridden by setting the :content_reducer to a function of type (t | Content.Stream.t -> reducer). Valid function formats are any callback variant, see Callback for more information.

config :resx,
    content_reducer: fn
        content = %{ type: ["x.native/erlang"|_] } -> &(&2.(:erlang.term_to_binary(Resx.Resource.Content.data(content)), &1))
        content -> &Enum.reduce(Resx.Resource.Content.Stream.new(content), &1, &2)
    end