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
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
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.
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.
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.
supported_bootstrap_themes()
Lists all supported bootstrap themes.
Currently, supported bootstrap themes are:
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:
- default
- cerulean
- cosmo
- cyborg
- darkly
- flatly
- journal
- litera
- lumen
- lux
- materia
- minty
- pulse
- sandstone
- simplex
- sketchy
- slate
- solar
- spacelab
- superhero
- united
- yeti
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") %>
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:
- default
- cerulean
- cosmo
- cyborg
- darkly
- flatly
- journal
- litera
- lumen
- lux
- materia
- minty
- pulse
- sandstone
- simplex
- sketchy
- slate
- solar
- spacelab
- superhero
- united
- yeti
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") %>