Created
June 17, 2016 00:33
-
-
Save enricodeleo/340a7819dce306ab8e56bd5dda533b04 to your computer and use it in GitHub Desktop.
Angular 1.x module that takes advantage of JST for templating
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
angular | |
.module('angularJst', []) | |
.config([ | |
'$provide', | |
function($provide) { | |
$provide.decorator('$templateCache', function($delegate, $sniffer) { | |
var originalGet = $delegate.get; | |
$delegate.get = function(key) { | |
var value; | |
value = originalGet(key); | |
if (!value) { | |
// JST is where my partials and other templates are stored | |
// If not already found in the cache, look there... | |
value = JST[key](); | |
if (value) { | |
$delegate.put(key, value); | |
} | |
} | |
return value; | |
}; | |
return $delegate; | |
}); | |
return this; | |
} | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment