The asset_tag module is accessible via the webhelpers.rails module.
Provides functionality for linking an HTML page together with other assets, such as images, javascripts, stylesheets, and feeds.
Returns a link tag allowing browsers and news readers (that support it) to auto-detect an RSS or ATOM feed for current page.
Examples:
>>> auto_discovery_link_tag('http://feed.com/feed.xml')
'<link href="http://feed.com/feed.xml" rel="alternate" title="RSS" type="application/rss+xml" />'
>>> auto_discovery_link_tag('http://feed.com/feed.xml', type='atom')
'<link href="http://feed.com/feed.xml" rel="alternate" title="ATOM" type="application/atom+xml" />'
>>> auto_discovery_link_tag('app.rss', type='atom', title='atom feed')
'<link href="app.rss" rel="alternate" title="atom feed" type="application/atom+xml" />'
>>> auto_discovery_link_tag('/app.html', type='text/html')
'<link href="/app.html" rel="alternate" title="" type="text/html" />'
Returns an image tag for the specified source.
Examples:
>>> image_tag('xml.png')
'<img alt="Xml" src="/images/xml.png" />'
>>> image_tag('rss.png', 'rss syndication')
'<img alt="rss syndication" src="/images/rss.png" />'
>>> image_tag("icon.png", size="16x10", alt="Edit Entry")
'<img alt="Edit Entry" height="10" src="/images/icon.png" width="16" />'
>>> image_tag("/icons/icon.gif", size="16x16")
'<img alt="Icon" height="16" src="/icons/icon.gif" width="16" />'
>>> image_tag("/icons/icon.gif", size="16x")
'<img alt="Icon" src="/icons/icon.gif" width="16" />'
Returns script include tags for the specified javascript sources.
Each source's URL path is prepended with '/javascripts/' unless their full path is specified. Each source's URL path is ultimately prepended with the environment's SCRIPT_NAME (the root path of the web application), unless the URL path is a full-fledged URL (e.g. http://example.com). Sources with no filename extension will be appended with the '.js' extension.
Optionally includes (prepended) WebHelpers' built-in javascripts when passed the builtins=True keyword argument.
Specify the keyword argument defer=True to enable the script defer attribute.
Examples:
>>> print javascript_include_tag(builtins=True)
<script src="/javascripts/prototype.js" type="text/javascript"></script>
<script src="/javascripts/scriptaculous.js" type="text/javascript"></script>
>>> print javascript_include_tag(builtins=True, defer=True)
<script defer="defer" src="/javascripts/prototype.js" type="text/javascript"></script>
<script defer="defer" src="/javascripts/scriptaculous.js" type="text/javascript"></script>
>>> print javascript_include_tag('prototype', '/other-javascripts/util.js')
<script src="/javascripts/prototype.js" type="text/javascript"></script>
<script src="/other-javascripts/util.js" type="text/javascript"></script>
>>> print javascript_include_tag('app', '/test/test.1.js', builtins=True)
<script src="/javascripts/prototype.js" type="text/javascript"></script>
<script src="/javascripts/scriptaculous.js" type="text/javascript"></script>
<script src="/javascripts/app.js" type="text/javascript"></script>
<script src="/test/test.1.js" type="text/javascript"></script>
Returns CSS link tags for the specified stylesheet sources.
Each source's URL path is prepended with '/stylesheets/' unless their full path is specified. Each source's URL path is ultimately prepended with the environment's SCRIPT_NAME (the root path of the web application), unless the URL path is a full-fledged URL (e.g. http://example.com). Sources with no filename extension will be appended with the '.css' extension.
Examples:
>>> stylesheet_link_tag('style')
'<link href="/stylesheets/style.css" media="screen" rel="Stylesheet" type="text/css" />'
>>> stylesheet_link_tag('dir/file', media='all')
'<link href="/stylesheets/dir/file.css" media="all" rel="Stylesheet" type="text/css" />'
>>> stylesheet_link_tag('/dir/file', media='all')
'<link href="/dir/file.css" media="all" rel="Stylesheet" type="text/css" />'
See the source for more information.