Support and Documentation

Filtering templates with file globbing

Most Brightspot themes have a large number of templates that address virtually all types of digital publishing. The following diagram shows a small subset of the templates available in default theme.

visible-styleguide-templates.svg

If your particular Brightspot project uses only some of those templates, you can filter the unneeded ones using the key visibleExamples in the configuration file _config.json. This reduces the number of extraneous templates designers see in the Styleguide UI. For example, if your Brightspot project only posts to social networks, you can filter the templates in Styleguide to only those associated with social networking.

The examples in the following sections use file globbing at the directory level; file globbing for template filtering is not available at the individual template level. For example, you can filter on templates matching the pattern /facebook/**/*, but not the pattern /facebook/**/OpenGraph*. See _hidden for information about hiding at the template level.

Filtering with a single glob

You can filter templates with a single glob within the theme's configuration file _config.json.

{
  "hiddenExamples": true,
  "visibleExamples": "/facebook/**/*"
}

In the previous snippet—

  • Line 2 activates the filtering mechanism. This line is mandatory.

  • Line 3 filters for templates matching the file glob <template_directory>/styleguide/facebook/**/*.

The following illustration shows the result of the above filter.

filter-single-glob.png
Filtering with multiple file globs

You can filter with multiple globs within the theme's configuration file _config.json. Using this technique you can display templates from multiple directories.

{
  "hiddenExamples": true,
  "visibleExamples": [
    "/facebook/**/*",
    "/googleplus/**/*",
    "/twitter/**/*"
  ]
}

Referring to the previous snippet, Styleguide displays the templates in only the following directories:

  • <template_directory>/styleguide/facebook/**/*

  • <template_directory>/styleguide/googleplus/**/*

  • <template_directory>/styleguide/twitter/**/*

Filtering on globs from template sources

Most Styleguide themes import templates from the default theme, and you may have customized themes that import templates from other themes as well. You can filter the imported templates using file globbing so only certain ones appear in the Styleguide UI.

{
  "sources": [
    {
      "source": "/styleguide",
      "hiddenExamples": true,
      "visibleExamples": "/facebook/**/*"
    }
  ]
}

In the previous snippet—

  • Line 2 activates the filtering mechanism. This line is mandatory.

  • Line 4 indicates that the current theme imports templates from the global theme directory brightspot/express/styleguide/.

  • Line 6 filters for templates in the directory facebook/ within the sourced directory. You can also use an array of file globs as explained in Filtering with multiple file globs.

. See also: