Semantic-Org/Semantic-UI · error

A valid template name was not specified.

Error message

A valid template name was not specified.

What it means

In generateResults() (search.js:1013-1018) the module looks up settings.templates[settings.type] and, after producing HTML, checks whether that template is a function; if it is not (undefined because the type is unknown or the template was overwritten with a non-function), it logs error.noTemplate. Results cannot be rendered without a template function.

Source

Thrown at src/definitions/modules/search.js:1303

  onResultsClose : function(){},

  className: {
    animating : 'animating',
    active    : 'active',
    empty     : 'empty',
    focus     : 'focus',
    hidden    : 'hidden',
    loading   : 'loading',
    results   : 'results',
    pressed   : 'down'
  },

  error : {
    source          : 'Cannot search. No source used, and Semantic API module was not included',
    noResults       : 'Your search returned no results',
    logging         : 'Error in debug logging, exiting.',
    noEndpoint      : 'No search endpoint was specified',
    noTemplate      : 'A valid template name was not specified.',
    oldSearchSyntax : 'searchFullText setting has been renamed fullTextSearch for consistency, please adjust your settings.',
    serverError     : 'There was an issue querying the server.',
    maxResults      : 'Results must be an array to use maxResults setting',
    method          : 'The method you called is not defined.'
  },

  metadata: {
    cache   : 'cache',
    results : 'results',
    result  : 'result'
  },

  regExp: {
    escape     : /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,
    beginsWith : '(?:\s|^)'
  },

  // maps api response attributes to internal representation

View on GitHub (pinned to 597843ab84)

Solutions

  1. Use a built-in type: 'standard' or 'category' (both have default templates).
  2. If you set type:'custom', also provide settings.templates.custom = function(response, fields){ return '...'; }.
  3. Ensure any template override remains a function returning an HTML string.

Example fix

// before
$('.ui.search').search({ type: 'fancy', source: data }); // no 'fancy' template -> [85]

// after
$('.ui.search').search({
  type: 'fancy',
  source: data,
  templates: { fancy: function(response, fields){ return '<div>...</div>'; } }
});
Defensive patterns

Strategy: type-guard

Validate before calling

var type = cfg.type || 'standard';
if (!$.isFunction(cfg.templates && cfg.templates[type])) {
  throw new Error("No template function for search type '" + type + "'");
}
$('.ui.search').search(cfg);

Type guard

function hasTemplate(cfg, type){ var t = (cfg.templates||{})[type||'standard']; return typeof t === 'function'; }

Prevention

When it happens

Trigger: settings.type set to a value with no matching entry in settings.templates (e.g. type:'custom' when only 'standard' and 'category' exist); overriding settings.templates.standard with a string/null instead of a function; calling .search() with type:'category' but no category template.

Common situations: Customizing the type option without supplying the matching template; removing the default templates when extending settings; version differences where a template key was renamed.

Related errors


AI-assisted analysis of Semantic-Org/Semantic-UI@597843ab84 (2026-08-13). Data as JSON: /api/errors/3ab1ac1148c03508. Report an issue: GitHub.