Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

0.9.0: loading helpers from verb config from package.json #92

Closed
tunnckoCore opened this issue Mar 19, 2016 · 6 comments · May be fixed by GerHobbelt/verb#18
Closed

0.9.0: loading helpers from verb config from package.json #92

tunnckoCore opened this issue Mar 19, 2016 · 6 comments · May be fixed by GerHobbelt/verb#18

Comments

@tunnckoCore
Copy link

@jonschlinkert as you mention. I think it not works.

"verb":
   "helpers": [
      "helper-simple-related"
    ],
}

in verb.md

{%= simpleRelated(verb.related.list) %}

and it outputs the returned simpleRelated function (see below). I followed helper-related pattern - module exports that exports function which returns async function.

module.exports = function (options) {
  return function simpleRelated (repos, opts, cb) {
    // code
    cb(null, res) // where `res` is the constructed string
  }
}
@jonschlinkert
Copy link
Member

sorry, I forgot to mention async helpers. try using:

"verb":
   "asyncHelpers": [
      "helper-simple-related"
    ],
}

it might not be supported yet, I'll look in a bit, but just wanted to mention it

@tunnckoCore
Copy link
Author

Hmm, yea, make sense. Will try.

@tunnckoCore
Copy link
Author

Nope. Not works.

[charlike@voltaire handle-arguments]$ verb
[03:22:50] starting readme generator
[03:22:50] starting readme:readme task
[03:22:50] starting readme generator
[03:22:50] finished readme generator 56ms
ReferenceError: simpleRelated is not defined
    at eval (engine.templateSources[1]:24:11)
    at /home/charlike/.nvm/versions/node/v5.8.0/lib/node_modules/verb/node_modules/engine-cache/index.js:201:17
    at Object.wrappedRender [as render] (/home/charlike/.nvm/versions/node/v5.8.0/lib/node_modules/verb/node_modules/engine-cache/index.js:256:7)
    at /home/charlike/.nvm/versions/node/v5.8.0/lib/node_modules/verb/node_modules/templates/lib/plugins/render.js:291:16
    at /home/charlike/.nvm/versions/node/v5.8.0/lib/node_modules/verb/node_modules/templates/lib/plugins/routes.js:133:7
    at /home/charlike/.nvm/versions/node/v5.8.0/lib/node_modules/verb/node_modules/en-route/lib/index.js:576:15
    at next (/home/charlike/.nvm/versions/node/v5.8.0/lib/node_modules/verb/node_modules/en-route/lib/index.js:161:14)
    at /home/charlike/.nvm/versions/node/v5.8.0/lib/node_modules/verb/node_modules/en-route/lib/index.js:183:18
    at Function.matchLayer (/home/charlike/.nvm/versions/node/v5.8.0/lib/node_modules/verb/node_modules/en-route/lib/index.js:264:3)
    at next (/home/charlike/.nvm/versions/node/v5.8.0/lib/node_modules/verb/node_modules/en-route/lib/index.js:164:10)
ENV: undefined

@jonschlinkert
Copy link
Member

k thx. want to do a pr to base-runner? basically you can copy the logic used for helpers (don't worry about duplicating code, all of those fields are going to be refactored anyway)

@stefanwalther
Copy link
Contributor

stefanwalther commented Aug 8, 2016

Are (non async) helpers supposed to work in current version of verb (0.9/dev)?

"verb":
   "helpers": [
      "helper-simple-related"
    ],
}

If I am not completely wrong, this already worked but seems to be broken now ...

@jonschlinkert
Copy link
Member

sync helpers work in 0.9.0. there are many sync helpers used in verb-generate-readme, just make sure you're exporting the correct signature.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants