code: public CmsTemplateLoaderFacade getTemplateLoaderFacade(
          CmsObject cms,
          HttpServletRequest request,
          CmsResource resource,
          String templateProperty)
      throws CmsException {
  
          String templateProp = cms.readPropertyObject(resource, templateProperty, true).getValue();
          CmsTemplateContext templateContext = null;
          String templateName = null;
          if (templateProp == null) {
  
              // use default template, if template is not set
              templateProp = DEFAULT_TEMPLATE;
              NamedTemplate namedTemplate = readTemplateWithName(cms, templateProp);
              if (namedTemplate == null) {
                  // no template property defined, this is a must for facade loaders
                  throw new CmsLoaderException(
                      Messages.get().container(Messages.ERR_NONDEF_PROP_2, templateProperty, cms.getSitePath(resource)));
              }
              templateName = namedTemplate.getName();
          } else {
              if (CmsTemplateContextManager.hasPropertyPrefix(templateProp)) {
                  templateContext = OpenCms.getTemplateContextManager().getTemplateContext(
                      templateProp,
                      cms,
                      request,
                      resource);
                  if (templateContext != null) {
                      templateProp = templateContext.getTemplatePath();
                  }
              }
              NamedTemplate namedTemplate = readTemplateWithName(cms, templateProp);
              if (namedTemplate == null) {
                  namedTemplate = readTemplateWithName(cms, DEFAULT_TEMPLATE);
                  if (namedTemplate != null) {
                      templateProp = DEFAULT_TEMPLATE;
                      templateName = namedTemplate.getName();
                  }
              } else {
                  templateName = namedTemplate.getName();
              }
          }
          CmsResource template = cms.readFile(templateProp, CmsResourceFilter.IGNORE_EXPIRATION);
          CmsTemplateLoaderFacade result = new CmsTemplateLoaderFacade(getLoader(template), resource, template);
          result.setTemplateContext(templateContext);
          result.setTemplateName(templateName);
          return result;
  
      }
docs: Returns a template loader facade for the given file.<p>
  @param cms the current OpenCms user context
  @param request the current request
  @param resource the requested file
  @param templateProperty the property to read for the template
  
  @return a resource loader facade for the given file
  @throws CmsException if something goes wrong