BigCommerce Stencil — load component parts based o

2020-08-03 06:29发布

问题:

I am using BigCommerce Stencil to make a theme. Currently {{> components/category/category}} will load the markup from components/category/category.html but now i want to do something like the following

  {{#if !isMobile}}
    {{> components/category/category}}
  {{else}}
    {{> components/category/category_mobile}}
  {{/if}}

to do that; I would need to make my own isMobile() function and return a {{isMobile}} out of it.

First attempt: https://stackoverflow.com/questions/44634630/frontend-need-for-handlebars-compile-but-handlebars-already-in-use-with-bigcomm?noredirect=1#comment76255240_44634630

Im open to any solutions. Im just fishing for new methodes of making these themes

Questions:

  1. Sense handlebars is working serverside; is this possibe?
  2. Can I reload handlebars on the frontend? (see the 1st attempt link above)
  3. if i can reload handle bars in the frontend in what ways can it theoretically work with the original serverside parsing to achieve the example logic above?