handlebars.jsdevelopment-environmentbigcommercecornerstone

Conditional for development environment in Bigcommerce's Handlebars


Working from the Cornerstone theme in Stencil, I want to be able to do different things depending on whether I am on my local NPM environment or the production site.

Looking at the current URL is not enough as the page has to be already loaded for that. I want to have conditionals in the template, with handlebars, when the markup is being generated. Something like:

{{#if developEnvironment '===' 'true'}}
  <p>I'm local</p>
{{else}}
  <p>I'm remote</p>
{{/if}}

I see nothing useful in the theme_settings vars.

Any ideas?


Solution

  • BigCommerce provides an actual key/value pair for determining if in development or not within the context.

    I'm using stencil CLI v2.1.0, so it might not be the case for older versions.

    {{#if in_development}}
     In Development
    {{else}}
     In Production
    {{/if}}