ForageWeb.Assets (forage v0.8.0)

Utilities to deal with static assets required by Forage's more advanced widgets, namely the select widgets.

Forage uses Bootstrap v4 instead of the newer Bootstrap v5.

Link to this section Summary

Functions

Enable serving forage assets from the phoenix application (instead of serving from a CDN).

Add to the end of the webpage in order to activate the forage select widget. Adds a <script> tag to the webpage.

Adds a <script> tag to the webpage with the javascript required to run the forage select widgets. Even after adding this code, you need to activate the select widget using ForageWeb.Assets.activate_forage_select()

Adds a <script> tag to the webpage with the javascript required to run the forage select widgets. Even after adding this code, you need to activate the select widget using ForageWeb.Assets.activate_forage_select()

Lists all supported bootstrap themes.

Renders the HTML <link> tag necessary to use a given Bootswatch theme, which are compatible with the default bootstrap classes. The theme is served from an external CDN.

Renders the HTML <link> tag necessary to use a given Bootswatch theme, which are compatible with the default bootstrap classes. The theme is served from an external CDN.

Link to this section Functions

Link to this macro

__using__(opts)

(macro)

Enable serving forage assets from the phoenix application (instead of serving from a CDN).

It's meant to be used in the Phoenix application's endpoint (just like the Plug.Static).

example

Example

defmodule MyAppWeb.Endpoint do
  use Phoenix.Endpoint, otp_app: :my_app
  # ...

  plug Plug.Static, ...

  use ForageWeb.Assets

  # ...
end
Link to this function

activate_forage_select()

Add to the end of the webpage in order to activate the forage select widget. Adds a <script> tag to the webpage.

Link to this function

forage_select_assets_from_app()

Adds a <script> tag to the webpage with the javascript required to run the forage select widgets. Even after adding this code, you need to activate the select widget using ForageWeb.Assets.activate_forage_select()

The Javascript is served from the phoenix application.

Link to this function

forage_select_assets_from_cdn()

Adds a <script> tag to the webpage with the javascript required to run the forage select widgets. Even after adding this code, you need to activate the select widget using ForageWeb.Assets.activate_forage_select()

The Javascript is served from an external CDN.

Link to this function

supported_bootstrap_themes()

Lists all supported bootstrap themes.

Currently, supported bootstrap themes are:

Link to this function

theme_from_app(theme)

Renders the HTML <link> tag necessary to use a given Bootswatch theme, which are compatible with the default bootstrap classes. The theme is served from an external CDN.

This function includes the default theme, which is the default bootstrap theme and not strictly part of bootswatch. The following themes are supported:

This is meant to be used inside the <head> tag of your application.

Note: no specific endorsement of Bootswatch themes is intended. They are included here simply because they are compatible with the default theme and may be a simple way of adding variety to your website.

examples

Examples

<%= ForageWeb.Assets.theme_from_app("superhero") %>
Link to this function

theme_from_cdn(theme)

Renders the HTML <link> tag necessary to use a given Bootswatch theme, which are compatible with the default bootstrap classes. The theme is served from an external CDN.

This function includes the default theme, which is the default bootstrap theme and not strictly part of bootswatch. The following themes are supported:

This is meant to be used inside the <head> tag of your application.

Note: no specific endorsement of Bootswatch themes is intended. They are included here simply because they are compatible with the default theme and may be a simple way of adding variety to your website.

The themes are served from the https://cdn.jsdelivr.net/ CDN.

examples

Examples

<%= ForageWeb.Assets.theme_from_cdn("superhero") %>