ICalendar (ICalendar v1.1.2) View Source
Generating ICalendars.
Link to this section Summary
Functions
To create a Phoenix/Plug controller and view that output ics format
Link to this section Functions
To create a Phoenix/Plug controller and view that output ics format:
Add to your config.exs:
config :phoenix, :format_encoders,
ics: ICalendarIn your controller use:
calendar = %ICalendar{ events: events }
render(conn, "index.ics", calendar: calendar)The important part here is .ics. This triggers the format_encoder.
In your view can put:
def render("index.ics", %{calendar: calendar}) do
calendar
end