Skip to content

API CSS To Link Tag

yasindilekci edited this page Sep 5, 2016 · 4 revisions

Description

Returns one HTML tag that links to the minify servlet that will combine and minify the CSS files in "filesOrGroups". The URL used for the href attribute is constructed using the toUrl(String, String, Host) method. Also see that method for how the "domain" and "host" parameters are used.

If in debug mode: a set of link tags (one for each referenced CSS file in "fileOrGroups") that directly links to the given CSS file. In this case nothing will be minified or combined. We are in debug mode if the URL that was used to do this request has a parameter with the name "debug". It's value does not matter.

If "extraAttributes" is provided its value will be included inside the tags. This can be handy in the case of additional information such as "media=print".

Important to know is that all relative references inside of the files (such as references to images inside a CSS file) will be relative from the location of the first file in "filesOrGroups". So do not mix files that are located in different folders.

Methods

This method comes has a few alternative signatures as you can see below. They all do the same thing, but the shorter ones use defaults for some of the attributes for convenience.

$cssMinifyTool.toLinkTag(filesOrGroups)
$cssMinifyTool.toLinkTag(filesOrGroups, host)
$cssMinifyTool.toLinkTag(filesOrGroups, domain)
$cssMinifyTool.toLinkTag(filesOrGroups, domain, host, extraAttributes)

Parameters

Field Type Description
filesOrGroups
required
String A comma separated list of file paths, or groups.
domain
optional
String The domain that should be used as the domain for the minifier URL. If no domain is provided the URL will be made relative. Setting this does not mean that the files in filesOrGroups will be retrieved from that server and minified, it just means that the domain of the generated Minify URL will point to that server. (For security reasons the Minifier does not load and minify files that are not located on one of the hosts of this dotCMS instance.). Setting this parameter is useful for things like using CDNs to host your content. Use null or "" to skip this parameter.
host
optional
com.dotmarketing.beans.Host The host where the given files can be found. Use null to skip this parameter.
extraAttributes
optional
String A string containing additional attributes that need to be added to the tags, such as "media=print". Use null or "" to skip this parameter.

Response

Returns one HTML tag that links to the minify servlet that will combine and minify the CSS files in "filesOrGroups".

Clone this wiki locally