forked from bertramdev/asset-pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AssetProcessorService: remove dependency on
LinkGenerator
Closes gh-40
- Loading branch information
Showing
3 changed files
with
24 additions
and
43 deletions.
There are no files selected for viewing
21 changes: 10 additions & 11 deletions
21
asset-pipeline-plugin/app/taglib/asset/pipeline/grails/AssetMethodTagLib.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,33 @@ | ||
package asset.pipeline.grails | ||
|
||
|
||
import static asset.pipeline.grails.UrlBase.* | ||
|
||
|
||
class AssetMethodTagLib { | ||
|
||
static namespace = 'g' | ||
static returnObjectForTags = ['assetPath'] | ||
|
||
|
||
AssetProcessorService assetProcessorService | ||
|
||
grails.web.mapping.LinkGenerator grailsLinkGenerator | ||
|
||
def assetPath = {final def attrs -> | ||
final def src | ||
final UrlBase urlBase | ||
final String baseUrl | ||
final boolean useManifest | ||
|
||
if (attrs instanceof Map) { | ||
src = attrs.src | ||
urlBase = attrs.absolute ? SERVER_BASE_URL : CONTEXT_PATH | ||
baseUrl = attrs.absolute ? grailsLinkGenerator.serverBaseURL : trimToEmpty(grailsLinkGenerator.contextPath) | ||
useManifest = attrs.useManifest ?: true | ||
} | ||
else { | ||
src = attrs | ||
urlBase = CONTEXT_PATH | ||
useManifest = true | ||
baseUrl = trimToEmpty(grailsLinkGenerator.contextPath) | ||
useManifest = true | ||
} | ||
|
||
return assetProcessorService.assetBaseUrl(request, urlBase) + assetProcessorService.getAssetPath(Objects.toString(src), useManifest) | ||
return assetProcessorService.assetBaseUrl(request, baseUrl) + assetProcessorService.getAssetPath(Objects.toString(src), useManifest) | ||
} | ||
|
||
private static String trimToEmpty(String str) { | ||
return str == null ? "" : str.trim() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters