Groovy Documentation

org.grails.plugin.resource
[Groovy] Class ResourceTagLib

java.lang.Object
  org.grails.plugin.resource.ResourceTagLib

class ResourceTagLib

This taglib handles creation of all the links to resources, including the smart de-duping of them. This is also a general-purpose linking tag library for writing links to resources. See resourceLink.

Authors:
Marc Palmer (marc@grailsrocks.com)
Luke Daley (ld@ldaley.com)


Property Summary
static java.lang.Object LINK_WRITERS

static java.lang.Object REQ_ATTR_PREFIX_AUTO_DISPOSITION

static java.lang.Object SUPPORTED_TYPES

java.lang.Object doResourceLink

Render a link for a resource.

java.lang.Object external

java.lang.Object grailsLinkGenerator

java.lang.Object grailsResourceProcessor

java.lang.Object img

Write out an HTML tag using resource processing for the image

java.lang.Object layoutResources

Render the resources.

static java.lang.Object namespace

java.lang.Object renderModule

Render the resources of the given module, and all its dependencies Boolean attribute "deferred" determines whether or not the JS with "defer:true" gets rendered or not

java.lang.Object require

Indicate that a page requires a named resource module This is stored in the request until layoutResources is called, we then sort out what needs rendering or not later

java.lang.Object resource

Get the URL for a resource

java.lang.Object resourceLink

Render an appropriate resource link for a resource - WHETHER IT IS PROCESSED BY THIS PLUGIN OR NOT.

java.lang.Object script

java.lang.Object stash

java.lang.Object style

java.lang.Object use

 
Constructor Summary
ResourceTagLib()

 
Method Summary
private java.lang.Object autoLayoutDone(java.lang.Object disposition)

boolean declareModuleRequiredByPage(java.lang.Object name, boolean mandatory = true)

private java.lang.Object determineResourceResolutionArguments(java.lang.Object url, java.util.Map attrs)

Produce standard map of arguments to use in resolving resource.

private java.lang.Object doStash(java.lang.Object attributes, java.lang.Object body)

protected java.lang.Object forcePrefixedWithSlash(java.lang.Object uri)

protected java.lang.Object getModuleByName(java.lang.Object name)

private java.lang.Object isAutoLayoutDone(java.lang.Object disposition)

private static java.lang.String makeAutoDispositionKey(java.lang.String disposition)

private void needsResourceLayout()

boolean notAlreadyIncludedResource(java.lang.Object url)

Check if a url has already been rendered.

java.lang.Object resolveLinkUriToUriAndResource(java.lang.Object attrs)

Get the uri to use for linking, and - if relevant - the resource instance.

static java.lang.Object writeAttrs(java.lang.Object attrs, java.lang.Object output)

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Property Detail

LINK_WRITERS

static java.lang.Object LINK_WRITERS


REQ_ATTR_PREFIX_AUTO_DISPOSITION

static java.lang.Object REQ_ATTR_PREFIX_AUTO_DISPOSITION


SUPPORTED_TYPES

static java.lang.Object SUPPORTED_TYPES


doResourceLink

java.lang.Object doResourceLink
Render a link for a resource.
attr:
uri to be written as the actual reference
attr:
type of link to produce, must be one of SUPPORTED_TYPES
attr:
... other attributes which will override constant attributes for the link type


external

java.lang.Object external


grailsLinkGenerator

java.lang.Object grailsLinkGenerator


grailsResourceProcessor

java.lang.Object grailsResourceProcessor


img

java.lang.Object img
Write out an HTML tag using resource processing for the image


layoutResources

java.lang.Object layoutResources
Render the resources. First invocation renders head JS and CSS, second renders deferred JS only, and any more spews.


namespace

static java.lang.Object namespace


renderModule

java.lang.Object renderModule
Render the resources of the given module, and all its dependencies Boolean attribute "deferred" determines whether or not the JS with "defer:true" gets rendered or not


require

java.lang.Object require
Indicate that a page requires a named resource module This is stored in the request until layoutResources is called, we then sort out what needs rendering or not later


resource

java.lang.Object resource
Get the URL for a resource
todo:
this currently won't work for absolute="true" invocations, it should just passthrough these


resourceLink

java.lang.Object resourceLink
Render an appropriate resource link for a resource - WHETHER IT IS PROCESSED BY THIS PLUGIN OR NOT. IMPORTANT: The point is that devs can use this for smart links in whether or not they are using the resource processing mechanisms. This gives utility to all, and allows us to have a single tag in Grails, meaning that users need make no changes when they move to install processing plugins like zipped-resources. This accepts a "url" attribute which is a Map like that passed to g.resource, or "uri" attribute which is an app-relative uri e.g. 'js/main.js or "plugin"/"dir"/"file" attributes like g.resource This is *not* just for use with declared resources, you can use it for anything e.g. feeds. The "type" attribute can override the type e.g. "rss" if the type cannot be extracted from the extension of the url.


script

java.lang.Object script


stash

java.lang.Object stash


style

java.lang.Object style


use

java.lang.Object use


 
Constructor Detail

ResourceTagLib

ResourceTagLib()


 
Method Detail

autoLayoutDone

private java.lang.Object autoLayoutDone(java.lang.Object disposition)


declareModuleRequiredByPage

boolean declareModuleRequiredByPage(java.lang.Object name, boolean mandatory = true)


determineResourceResolutionArguments

private java.lang.Object determineResourceResolutionArguments(java.lang.Object url, java.util.Map attrs)
Produce standard map of arguments to use in resolving resource.
Parameters:
url
attrs
Returns:


doStash

private java.lang.Object doStash(java.lang.Object attributes, java.lang.Object body)


forcePrefixedWithSlash

protected java.lang.Object forcePrefixedWithSlash(java.lang.Object uri)


getModuleByName

protected java.lang.Object getModuleByName(java.lang.Object name)


isAutoLayoutDone

private java.lang.Object isAutoLayoutDone(java.lang.Object disposition)


makeAutoDispositionKey

private static java.lang.String makeAutoDispositionKey(java.lang.String disposition)


needsResourceLayout

private void needsResourceLayout()


notAlreadyIncludedResource

boolean notAlreadyIncludedResource(java.lang.Object url)
Check if a url has already been rendered.
Parameters:
url
Returns:
true if not already rendered


resolveLinkUriToUriAndResource

java.lang.Object resolveLinkUriToUriAndResource(java.lang.Object attrs)
Get the uri to use for linking, and - if relevant - the resource instance. NOTE: The URI handling mechanics in here are pretty evil and nuanced (i.e. ad-hoc vs declared, ad-hoc and not found, ad-hoc and excluded etc). There is reasonable test coverage, but only fools rush in.
attr:
uri - to be resolved, i.e. id of the ResourceMeta
attr:
disposition - of the resource
Returns:
Map with uri/url property and *maybe* a resource property


writeAttrs

static java.lang.Object writeAttrs(java.lang.Object attrs, java.lang.Object output)


 

Groovy Documentation