 						candidateHooksInvoked = {}
 						
 						# Insert and compile the template HTML if it exists.
-						if skinAssets.templates[candidate]
+						if skinAssets?.templates?[candidate]
 						
 							# Insert and compile HTML.
 							element.html skinAssets.templates[candidate]

			# compilation step.
			link = directive.link
			directive.link = (scope, element, attrs, controller) ->
			
				# Save top-level arguments for later calls to link functions.
				topLevelArgs = arguments
				

				
				recalculateCandidate = ->
				
					# Get the skin assets.
					skinAssets = config.get(
						"packageConfig:shrub-skin:assets:#{currentSkinKey}"
					)
					
					# Track changes to the current template candidate.
					oldCandidate = candidate
					
