Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 前端需要把手。编译。但bigcommerce服务器端已经使用了把手_Javascript_Jquery_Mobile_Handlebars.js_Bigcommerce - Fatal编程技术网

Javascript 前端需要把手。编译。但bigcommerce服务器端已经使用了把手

Javascript 前端需要把手。编译。但bigcommerce服务器端已经使用了把手,javascript,jquery,mobile,handlebars.js,bigcommerce,Javascript,Jquery,Mobile,Handlebars.js,Bigcommerce,我正在开发一个bigcommerce模板主题。我想使用基本的把手功能,如 标记 <div id="mobile"></div> <script id="mobile_category_template" type="text/x-handlebars-template"> <div class="entry"> <h1>{{var}}</h1> <div cl

我正在开发一个bigcommerce模板主题。我想使用基本的把手功能,如

标记

    <div id="mobile"></div>
    <script id="mobile_category_template" type="text/x-handlebars-template">
      <div class="entry">
        <h1>{{var}}</h1>
        <div class="body">
          <p>body</p>
        </div>
      </div>
    </script>
    <script src="{{cdn 'https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.10/handlebars.min.js'}}"></script>
    <script src="{{cdn '/assets/js/category.js'}}"></script>
这通常是可行的。但是bigcommerce解析Handlebar
serverside
。当我的前端手柄解析时,
{{{var}}
已经编译好了。我怎样才能使上述功能与服务器端把手分开工作?或者如何制作和/或扩展当前的把手逻辑。(基本上如何定义我自己的模板变量/放置)

非常明确。我想根据所使用的视口或浏览器来决定加载
{{>components/mobile}
{{>components/desktop}
(使用javascript可以轻松完成)


这就是我想要解决的问题:

您无法扩展编译服务器端的当前逻辑。你可以有一个Handlebar的客户端实现来支持这一点,但是如果你明确你想要实现什么样的功能,这会有所帮助。嗨@Alyss!这个链接提出了一个更具体的问题@Alyss“
你可以有一个Handlebar的客户端实现
”这听起来很有趣。这里有一个很好的例子和讨论:@Alyss我认为我不能
{{{{{raw helper}}}}
    var hitTemplate = Handlebars.compile($("#mobile_category_template").html());
    $(".collection-page").html(hitTemplate({
      var: "var works"
    }));