Skip to content

Instantly share code, notes, and snippets.

@enricodeleo
Created June 17, 2016 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enricodeleo/340a7819dce306ab8e56bd5dda533b04 to your computer and use it in GitHub Desktop.
Save enricodeleo/340a7819dce306ab8e56bd5dda533b04 to your computer and use it in GitHub Desktop.
Angular 1.x module that takes advantage of JST for templating
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