如何/在哪里使用模板中的自定义Handlbars助手? [英] How/Where to use Custom Handlbars Helpers in Stencil?

查看:271
本文介绍了如何/在哪里使用模板中的自定义Handlbars助手?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我熟悉如何编写自定义Handlebars Helper,但是我在哪里可以将帮助代码放在文件中?

我试过包括我自己的JS文件在头部和正文后,但我在JS控制台中得到以下错误:


未捕获的ReferenceError:Handlebars未定义


我做错了什么或者这是Handlebars Stencil实现的'特征'?



所有帮助非常感谢!

解决方案

所有助手都是预定义的,可以与Stencil一起使用natively 。如果你想注册你自己的,你需要包括把手作为你的主题的一部分,并创建他们的客户端。

I'm familiar with how to code a custom Handlebars Helper, but where do I put the helper code within the files?

I've tried including my own JS file in the head and after the body, but I get the following error in the JS console:

Uncaught ReferenceError: Handlebars is not defined

Am I doing something wrong or is this a 'feature' of the Stencil implementation of Handlebars?

All help greatly appreciated!

解决方案

All the helpers are predefined that can be used with Stencil "natively". If you'd like to register your own, you'd need to include handlebars as apart of your theme and create them clientside.

这篇关于如何/在哪里使用模板中的自定义Handlbars助手?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆