Ensure that there is a correctly populated template_hash.

        Check for a correctly populated template_hash and create if it doesn't
        already exist.
509923
def ensure_hash(self):
        
        fields = self.table.fieldnames
        if 'template_hash' in fields:
            return

        # The fields to use in making a template hash
        hash_fields = ['mass1', 'mass2', 'inclination',
                       'spin1x', 'spin1y', 'spin1z',
                       'spin2x', 'spin2y', 'spin2z',]

        fields = [f for f in hash_fields if f in fields]
        template_hash = np.array([hash(v) for v in zip(*[self.table[p]
                                  for p in fields])])
        self.table = self.table.add_fields(template_hash, 'template_hash')
495703
def use_all_templates
      Utils.available_templates.each do |ext, template|
        next if engines(ext)
        register_engine ext, template
      end
    end
334701
def build(template_directories):
    
    template = load_template(template_directories[0])
    for directory in template_directories[1:]:
        template.update(load_template(directory))
    return template
1237524
def _ensure_exists(wrapped):
    '''
    
    '''
    @functools.wraps(wrapped)
    def check_exists(name, *args, **kwargs):
        if not exists(name):
            raise CommandExecutionError(
                'Container \'{0}\' does not exist'.format(name)
            )
        return wrapped(name, *args, **salt.utils.args.clean_kwargs(**kwargs))
    return check_exists
600269
def find_template_with_lookup(name, prefix = nil, partial = false)
      if prefix == controller_path
        folder = controller.find_inheritable_template_folder(name, partial)
        prefix = folder if folder
      end
      find_template_without_lookup(name, prefix, partial)
    end
626334
def ensure_context_attribute_exists(context, name, default_value=None):
    
    if not hasattr(context, name):
        setattr(context, name, default_value)
773990
def _get_template(self, template_name):
        
        if template_name not in self.chached_templates:
            self.chached_templates[template_name] = self.env.get_template(template_name)
        return self.chached_templates[template_name]
782430
def prepare_context(env)
      context = Roger::Template::TemplateContext.new(self, env)

      # Extend context with all helpers
      self.class.helpers.each do |mod|
        context.extend(mod)
      end

      context
    end
382791
def handle_known_template_id(template_id)
      case template_id
      when VARIABLE_TEMPLATE
        @derivation_operator = HQMF::DataCriteria::INTERSECT if @derivation_operator == HQMF::DataCriteria::XPRODUCT
        @definition ||= 'derived'
        @variable = true
        @negation = false
      when SATISFIES_ANY_TEMPLATE
        @definition = HQMF::DataCriteria::SATISFIES_ANY
        @negation = false
      when SATISFIES_ALL_TEMPLATE
        @definition = HQMF::DataCriteria::SATISFIES_ALL
        @derivation_operator = HQMF::DataCriteria::INTERSECT
        @negation = false
      else
        return false
      end
      true
    end
393266
def get_template(filename_or_string, is_string=False):
    '''
    
    '''

    # Cache against string sha or just the filename
    cache_key = sha1_hash(filename_or_string) if is_string else filename_or_string

    if cache_key in TEMPLATES:
        return TEMPLATES[cache_key]

    if is_string:
        # Set the input string as our template
        template_string = filename_or_string

    else:
        # Load template data into memory
        with open(filename_or_string, 'r') as file_io:
            template_string = file_io.read()

    TEMPLATES[cache_key] = Template(template_string, keep_trailing_newline=True)
    return TEMPLATES[cache_key]
446085
public function useTemplate($template_name = false)
    {
        $templates = $this->getTemplates();

        // set the default template
        if ($template_name == false) {
            $template_name = $templates[0]->name;
        }

        // actually use the template
        if ($template_name) {
            $this->{$template_name}();
        }
    }
279102
def add_template(self, tpl):
        
        tpl = self.index_template(tpl)
        self.templates[tpl.uuid] = tpl
359913
function() {
        var self = this;

        var template = this.getTemplate();

        // Optionally bail out if the default selection
        // is not given (user calls applyTemplate() manually)
        if(!this.config.selector) {
            return;
        }

        $(this.config.selector).each(function() {

            var $this = $(this);

            // Template already applied
            if($this.hasClass("bitcoin-address-controls")) {
                return;
            }

            // Make sure we don't apply the template on the template itself
            if($this.parents("#" + self.config.template).size() > 0) {
                return;
            }

            // Don't reapply templates on subsequent scans

            self.applyTemplate($this, template);
        });
    }
1319071
def _prepare_template(self, obj, needs_request=False):
        
        if self.instance_name is None and self.template_name is None:
            raise SearchFieldError("This field requires either its instance_name variable to be populated or an explicit template_name in order to load the correct template.")

        if self.template_name is not None:
            template_names = self.template_name

            if not isinstance(template_names, (list, tuple)):
                template_names = [template_names]
        else:
            template_names = ['search/indexes/%s/%s_%s.txt' % (obj._meta.app_label, obj._meta.module_name, self.instance_name)]

        t = loader.select_template(template_names)
        ctx = {'object': obj}
        if needs_request:
            request = rf.get("/")
            request.session = {}
            ctx['request'] = request
        return t.render(Context(ctx))
943929
def update_template(self, template_id, template_dict):
        
        return self._create_put_request(
            resource=TEMPLATES,
            billomat_id=template_id,
            send_data=template_dict
        )
385705
def template_exists_db(self, template):
        
        name = utils.camel_to_snake(template[0]).upper()
        language = utils.camel_to_snake(template[3])
        try:
            models.EmailTemplate.objects.get(name=name, language=language)
        except models.EmailTemplate.DoesNotExist:
            return False
        return True
438227
def enable_template(name)
      name = name.to_sym

      return false if @enabled_templates.include?(name)

      unless (template_dir = Template.templates[name])
        say "Unknown template #{name}", :red
        exit -1
      end

      new_template = Template::Directory.new(template_dir)

      # mark the template as enabled
      @enabled_templates << name

      # enable any other templates
      new_template.enable.each do |sub_template|
        enable_template(sub_template)
      end

      # append the new template to the end of the list,
      # to override previously loaded templates
      @templates << new_template

      # add the template directory to the source-paths
      self.source_paths << new_template.path
      return true
    end