当前位置:  开发笔记 > 程序员 > 正文

函数调用和检查结果在DustJs中

如何解决《函数调用和检查结果在DustJs中》经验,为你挑选了0个好方法。

我将连接角色与灰尘模板ejs模板结合起来就像这种语法

<% if (userCan('impersonate')) { %>
  
<% } %>  

那是在玉

if userCan('impersonate')
  button#impersonate Impersonate

怎么在灰尘中这样做?

            {@eq key=userCan('edit data') value="true" }
                Edit
                Delete
            {:else}

            {/eq}

这段代码给我一个错误

Wed, 06 Jan 2016 16:57:47 GMT uncaughtException Expected end tag for assets but it was not found. At line : 42, column : 13

编辑:我有这个 {@contextDump key="full"/}

   "tail": {},
  "isObject": true,
  "head": {
    "enrouten": {
      "routes": {},
      "path": "function path(name, data) {var route;route = this.routes[name];if (typeof route === 'string') {return path2regexp.compile(route)(data);}return undefined;}"
    },
    "userIs": "function (action) {var act = ert(req, action);return roles.test(req, act)}",
    "userCan": "function (action) {var act = ert(req, action);return roles.test(req, act)}",
    "isAuthenticated": "function () { [native code] }",
    "_csrf": "FSaqN0PWxOF4slTUfnGHXJ0NkPOTJFl0u57eM=",
    "title": "?????????? ????????????",
    "assets": [
      {
        "ID_ASSET": 1,
        "SYMBOL_KODE": "12.TR.18",
        "DOK_NAME": "??9042",
        "DESCRIPTION": "?????????? ??????????????? ??9042",
        "DATE_RELISE": "2001-10-04T21:00:00.000Z",
        "POS_KODE": "pos kode 1                                                                                                                                                                                                                                                     ",

这是我的控制者

    router.get('/',  function (req, res) {
   var context = {
   req: req, // from Express callback
   userCan: function(chunk, context, bodies, params) {
     var permission = context.resolve(params.permission);
     return context.get('req').userCan(permission);
   }
 }
    models.SPR_ASSET.findAll({
      include: [ models.SPR_TYPE_UM, models.SPR_TYPE_ASSETS,  models.SPR_ASSETS_DS ]
    }).then(function(assets) {
      res.render('assets', {
        title: '?????????? ????????????',
        assets: assets
        context: context
      });
    });

var context 这里没用

推荐阅读
贾志军
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有