class WebJarsUtil extends AnyRef
WebJars Util
Config:
webjars.filter-expression can be used to declare a regex for the files that should be looked for when searching within WebJars. By default all files are searched for.
webjars.cdn-url overrides the default CDN url (https://cdn.jsdelivr.net/webjars)
webjars.use-cdn toggles the CDN
- Annotations
- @Singleton()
- Alphabetic
- By Inheritance
- WebJarsUtil
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
WebJarsUtil(configuration: Configuration, environment: Environment)
- Annotations
- @Inject()
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
- lazy val cdnUrl: String
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
css(webJar: String, path: String): String
A CSS link tag
A CSS link tag
- webJar
Name of the WebJar
- path
A path to an asset in the WebJar
- returns
A string with the tag or an error / empty string (depending on mode)
-
def
css(path: String): String
A CSS link tag
A CSS link tag
- path
A call that will become a url
- returns
A string with the tag or an error / empty string (depending on mode)
-
def
css(call: Call): String
A CSS link tag
A CSS link tag
- call
A call that will become a url
- returns
A string with the tag or an error / empty string (depending on mode)
-
def
css(urlTry: Try[String]): String
A CSS link tag
A CSS link tag
- urlTry
A possible url
- returns
A string with the tag or an error / empty string (depending on mode)
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
fullPath(webjar: String, path: String): Try[String]
Get the full path to a file in a WebJar without validating that the file actually exists
Get the full path to a file in a WebJar without validating that the file actually exists
- webjar
the WebJar artifactId
- path
the full path to a file in the WebJar
- returns
the path to the file (sans-the webjars prefix)
Calling fullPath("react", "react.js") will return the full path to the file in the WebJar because react.js exists at the root of the WebJar
Example: -
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
groupId(path: String): Try[String]
Get the groupId from a path
Get the groupId from a path
- path
a string to parse a WebJar name from
- returns
the artifact groupId based on the classpath
groupId("jquery/1.9.0/jquery.js") will return "org.webjars" if the classpath contains the org.webjars jquery jar
Example: -
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
def
img(webJar: String, path: String): String
A script tag
A script tag
- webJar
Name of the WebJar
- path
A path to an asset in the WebJar
- returns
A string with the tag or an error / empty string (depending on mode)
-
def
img(path: String): String
A img tag
A img tag
- path
A path that becomes a url
- returns
A string with the tag or an error / empty string (depending on mode)
-
def
img(call: Call): String
A img tag
A img tag
- call
A call that becomes a url
- returns
A string with the tag or an error / empty string (depending on mode)
-
def
img(urlTry: Try[String], otherParams: Map[String, String] = Map.empty[String, String]): String
A img tag
A img tag
- urlTry
A possible url
- otherParams
Other params for the script tag
- returns
A string with the tag or an error / empty string (depending on mode)
-
def
imgWithParams(webJar: String, path: String, otherParams: Map[String, String]): String
A img tag
A img tag
- webJar
Name of the WebJar
- path
A path to an asset in the WebJar
- otherParams
Other params to add to the script tag
- returns
A string with the tag or an error / empty string (depending on mode)
-
def
imgWithParams(path: String, otherParams: Map[String, String]): String
A img tag
A img tag
- path
A path to an asset in the WebJar
- otherParams
Other params to add to the script tag
- returns
A string with the tag or an error / empty string (depending on mode)
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
localOrCdnUrl(pathTry: Try[String]): Try[String]
Based on config, either returns a local url or a cdn url for a given asset path
Based on config, either returns a local url or a cdn url for a given asset path
- pathTry
Possibly a path to convert to a local url or cdn url
- returns
Possibly the local or cdn url
-
def
locate(webJar: String, path: String): Try[String]
Locate a file in a WebJar
Locate a file in a WebJar
- webJar
the WebJar artifactId
- path
the file or partial path to find
- returns
the path to the file (sans-the webjars prefix)
-
def
locate(file: String): Try[String]
Locate a file in a WebJar
Locate a file in a WebJar
- file
the file or partial path to find
- returns
the path to the file (sans-the webjars prefix)
Passing in
jquery.min.jswill returnjquery/1.8.2/jquery.min.jsassuming the jquery WebJar version 1.8.2 is on the classpath
Example: -
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
requireJs(mainUrl: Call): String
Generates the RequireJS config and main script tags
Generates the RequireJS config and main script tags
- mainUrl
The reverse route of the main app
- returns
The RequireJS config and main script tags
-
def
script(webJar: String, path: String): String
A script tag
A script tag
- webJar
Name of the WebJar
- path
A path to an asset in the WebJar
- returns
A string with the tag or an error / empty string (depending on mode)
-
def
script(path: String): String
A script tag
A script tag
- path
A path that becomes a url
- returns
A string with the tag or an error / empty string (depending on mode)
-
def
script(call: Call): String
A script tag
A script tag
- call
A call that becomes a url
- returns
A string with the tag or an error / empty string (depending on mode)
-
def
script(urlTry: Try[String], otherParams: Map[String, String] = Map.empty[String, String]): String
A script tag
A script tag
- urlTry
A possible url
- otherParams
Other params for the script tag
- returns
A string with the tag or an error / empty string (depending on mode)
-
def
scriptWithParams(webJar: String, path: String, otherParams: Map[String, String]): String
A script tag
A script tag
- webJar
Name of the WebJar
- path
A path to an asset in the WebJar
- otherParams
Other params to add to the script tag
- returns
A string with the tag or an error / empty string (depending on mode)
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
tag(path: String)(f: (String) ⇒ String): String
Turns a path into a tag using a provided function.
Turns a path into a tag using a provided function. Uses the mode of the application to determine if an error should be returned or not.
- path
The partial path of a file in a WebJar
- f
A function that will render a successful url
- returns
The tag to be rendered or when there is an error, an emtpy string in Prod mode and an error comment otherwise
-
def
tag(urlTry: Try[String])(f: (String) ⇒ String): String
Turns a possible url into a tag using a provided function.
Turns a possible url into a tag using a provided function. Uses the mode of the application to determine if an error should be returned or not.
- urlTry
A possible url
- f
A function that will render a successful url
- returns
The tag to be rendered or when there is an error, an emtpy string in Prod mode and an error comment otherwise
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
url(webJar: String, path: String): Try[String]
Locates a WebJar from a partial path and returns the reverse route
Locates a WebJar from a partial path and returns the reverse route
- webJar
The artifact name of the WebJar
- path
The partial path of a file in a WebJar
- returns
The reverse route to the WebJar asset
-
def
url(path: String): Try[String]
Locates a WebJar from a partial path and returns the reverse route or CDN URL
Locates a WebJar from a partial path and returns the reverse route or CDN URL
- path
The partial path of a file in a WebJar
- returns
The reverse route to the WebJar asset
- lazy val useCdn: Boolean
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
- lazy val webJarFilterExpr: String