HTML Helpers

This topic applies to

Applies to

SuiteCommerce Web Stores

The following four Handlebars.js helpers provide a means to maintain dynamic paths to your assets when customizing HTML templates.

getExtensionAssetsPath(default_value)

Use this HTML template helper:

  • To access pre-existing assets included with an active extension

  • In your extension overrides (templates)

Note

The default_value argument is the relative path to the asset.


Example Syntax in a Template File:

The following is an example of how to use this helper in an HTML template:

<img src="{{ getExtensionAssetsPath 'img/logo.png' }}">

Example Result:

This helper returns the active extension’s asset path (where <FULL_PATH> is the SSP Application base path):

<FULL_PATH>/extensions/<VENDOR>/<EXTENSION>/<VERSION>/img/logo.png

getExtensionAssetsPathWithDefault(config_value, default_value)

Use this HTML template helper:

  • To access pre-existing assets included with an active extension

  • In your extension overrides (templates)

  • When you expect that the asset has a configured path in NetSuite, but want to provide a default path if the configuration does not exist.

Note

The first argument (config_value) is the path as configured in NetSuite. In cases where the asset is not configured, you provide a fallback path (default_value) to be retrieved from the extension’s assets.


Example Syntax in a Template File:

The following is an example of how to use this helper in an HTML template:

<img src="{{getExtensionAssetsPathWithDefault logo_path 'img/logo.png' }}" >

Example Result:

This helper returns the active extension’s asset path. If the first argument is defined, this helper returns the path as configured in NetSuite:

<MY_PATH>/img/other_logo.png

If the first argument is undefined, this helper uses the second argument to return the correct path of the active extension:

<FULL_PATH>/extensions/<VENDOR>/<EXTENSION>/<VERSION>/img/logo.png

getThemeAssetsPath(default_value)

Use this HTML template helper:

  • To access new and pre-existing assets included in your theme directory

  • In your extension overrides (templates)

  • In your theme customizations (templates)

Using this helper, default_value is the relative path to the asset.

Example Syntax in Template File:

<img src="{{ getThemeAssetsPath 'img/logo.png' }}" >

Example Result:

This helper returns the active theme’s asset path (where <FULL_PATH> is the SSP Application base path):

<FULL_PATH>/extensions/<VENDOR>/<THEME_NAME>/<VERSION>/img/logo.png

getThemeAssetsPathWithDefault(config_value, default_value)

Use this HTML template helper:

  • To access new and pre-existing assets included in your theme directory

  • In your extension overrides (templates)

  • In your theme customizations (templates)

  • When you expect that the asset has a configured path in NetSuite, but want to provide a default path if the configuration does not exist.

Using this helper, config_value is the path as configured in NetSuite. In cases where the asset is not configured, you provide a fallback path (default_value) to be retrieved from the extension’s assets.

Example Syntax in Template File:

<img src="{{ getThemeAssetsPathWithDefault logo_path 'img/logo.png' }}" >

Example Result:

This helper returns the active theme’s asset path. If the first argument is defined, this helper returns the path as configured in NetSuite:

<MY_PATH>/img/other_logo.png

If the first argument is undefined, this helper uses the second argument to return the correct path of the active theme:

<FULL_PATH>/extensions/<VENDOR>/<THEME_NAME>/<VERSION>/img/logo.png

Related Topics