简体   繁体   English

是否可以在本地流星包内使用翡翠?

[英]Is it possible to use jade inside a local meteor package?

While trying to split up my meteor application in separate packages I encountered a problem when trying to encapsulate templates. 尝试将流星应用程序拆分为单独的程序包时,在尝试封装模板时遇到问题。 The package name would be gs-users : 软件包名称为gs-users

packages/gs-users/package.js 包/ GS-用户/ package.js

Package.onUse(function(api) {
    api.versionsFrom('1.1.0.2');
    api.use('mquandalle:jade');
    api.addFiles('views/list.jade');
    api.addFiles('gs-users.js');
});

My template file packages/gs-users/views/list.jade : 我的模板文件packages / gs-users / views / list.jade

template(name="GsUsersList")
    p Ola señior!!

Inside my main applications route definition ( lib/routes.js ): 在我的主要应用程序中,路由定义( lib / routes.js ):

Router.route('/', function() {
    this.render('GsUsersList');
});

Meteor now complains: Couldn't find a template named "GsUsersList" or "gsUsersList". Are you sure you defined it? 流星现在抱怨: Couldn't find a template named "GsUsersList" or "gsUsersList". Are you sure you defined it? Couldn't find a template named "GsUsersList" or "gsUsersList". Are you sure you defined it?

When using the templating package instead of mquandalle:jade and .html files instead of .jade files inside the gs-users package everything works fine. 当使用templating包而不是gs-users包内的mquandalle:jade和.html文件而不是.jade文件时,一切正常。 But I really hate plain HTML ;) 但是我真的很讨厌纯HTML;)

The solution is more simple than I thought. 解决方案比我想象的要简单。 Just use waitingkuo:jade instead of mquandalle:jade and add templating as a dependency: 只需使用waitingkuo:jade而不是mquandalle:jade并将templating添加为依赖项即可:

Package.onUse(function(api) {
  api.versionsFrom('1.1.0.3');
  api.use('waitingkuo:jade');
  api.use('templating');
  api.addFiles([
    'le-template.jade',
  ], ['client']);
});

Works like a charm! 奇迹般有效!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM