(Quick Reference)

r:external Tag

This tag renders the right kind of links to external resources, based on their type, never including the same resource multiple times. Resources, which are already included in a bundle are not to be rendered with this tag, but require and <r:layoutResources/> should be used instead.

For example CSS files are rendered with:

<link rel="stylesheet" .../>

or JS files are rendered with <script> tags. Images are rendered as favicons.

This is used internally by <r:layoutResources/>, and is rarely used on its own unless you must render links to resources without using the dependency mechanism and require. Resources that are included in a bundle, and have a disposition set to "defer", cannot be rendered directly with this tag.

Attributes

  • uri - Optional. The app-relative URI of the resource, i.e. "/css/main.css". Used as an alternative to dir/file combination
  • file - Optional. The file attribute as used by g:resource
  • dir - Optional. The dir attribute as used by g:resource. Defaults to "images"
  • plugin - Optional. The plugin attribute as used by g:resource
  • type - Optional. The type of link to render, from the supported list Default is chosen based on file extension but you can override with this, e.g. to treat a ".less" file as a "CSS" file when rendering the link.
  • wrapper - Optional. A Closure taking a single parameter, the result of which will be used to render the link. The link markup is passed in as the parameter, so this can be used to wrap the link in something like MS IE specific markup.

Note that all other attributes are passed through to the target tag, overriding any defaults.

The types supported are:

  • css - Sets type="text/css", rel="stylesheet", media="screen, projection"
  • js - Sets type="text/javascript", writer="js"
  • gif - Sets rel="shortcut icon"
  • jpg - Sets rel="shortcut icon"
  • ico - Sets rel="shortcut icon"
  • png - Sets rel="shortcut icon"
  • appleicon - Sets rel="apple-touch-icon"