BigCommerce Stencil — load component parts based on custom javascript logic

岁酱吖の 提交于 2019-12-08 11:35:07

问题


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?

来源:https://stackoverflow.com/questions/44634986/bigcommerce-stencil-load-component-parts-based-on-custom-javascript-logic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!