Created
October 18, 2013 13:07
-
-
Save ben-caplan/7041276 to your computer and use it in GitHub Desktop.
Add script macro
This file contains hidden or 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
#* | |
ADD SCRIPT MACRO | |
@use #addScript( $scriptPath ) | |
*# | |
#set( $scriptArray = [] )## | |
#macro( addScript $src )## | |
## CHECK TO MAKE SURE THAT VARS HAVE BEEN SET | |
#if( $UtilMethods.isSet($src) )## | |
#set( $scriptInMap = 'false' )## | |
## LOOP THROUGH MAP TO SEE IF $SRC IS ALREADY IN THE LIST | |
#foreach( $i in $scriptArray )## | |
#if( $scriptArray[$i] == $src )## | |
#set( $scriptInMap = 'true' )## | |
<!-- The script $src has already been included... --> | |
#end## | |
#end## | |
## CHECK TO SEE IF NAME HAS ALREAD BEEN USED | |
#if( $scriptInMap == 'false' )## | |
$scriptArray.add($src) | |
#set($cachebuster = $webapi.getLiveFileAsset($webapi.getIdentifierByURI("${src}")).getModDate().getTime())## | |
<script type="text/javascript" href="${src}?${cachebuster}"></script> | |
#end## | |
#end## | |
#end## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment