question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

0.9.0: Adding helpers from `verbfile.js`?

See original GitHub issue

That’s strange. I tried in a couple of ways that i know that it should work. Also checked how it’s done on other libs and generators.

The #91 “problem” push me to try some things and start playing with toc options and verb in general. In a result I realize couple of things:

  • there’s no toc template helper - e.g. using {%= toc() %}
  • you can’t pass options for toc through <!-- toc -->
    • i seen somewhere thing like <!-- toc('*.md', opts) -->
    • so i tried toc('README.md', {filter: fn}), but not works - the html comment is the same
  • can’t overwrite toc options? - the easiest way to try that was to add toc: {footer: 'foo'} to pkg
  • then i tried to add to verbfile (exposing function) some sync helper manually
    • tried using it in verbfile {%= foo('bar') %} and failed with foo is not defined
    • tried verb.helper('foo', require('helper-date')) - again fails with foo is not defined
    • tried to create task, add above to it and execute it - not works.
    • tried using verb.extendWith and put some tasks/helpers in it - not works.

So, couple of problems

  • there’s a need to expose helper-toc to template, b/c currently it only can be from <!-- -->
  • there’s no way to add filter (in general any) options to toc, neither through config and template
  • there’s some problem adding helpers

edit: Tried everything that I can think for. edit2: One of the tried ways:

'use strict'

module.exports = function generator(verb) {
  verb.extendWith(function (app) {
    // console.log('app', app)
    app.task('foobar', function (cb) {
      console.log('actual')
      app.helper('foo', function () {
        console.log('helper')
        return 123
      })
      cb()
    })
    app.build('foobar', function (err, res) {
      console.log('build', err, res)
    })
  })
}

Fails with foo is not defined

[charlike@voltaire async-simple-iterator]$ verb
[20:00:54] using verbfile ~/dev/__play/async-simple-iterator/verbfile.js
[20:00:54] starting default generator
[20:00:54] starting default:foobar task
actual
[20:00:54] finished default:foobar task 2ms
[20:00:54] finished default generator 14ms
build undefined undefined
[20:00:54] starting readme generator
[20:00:54] starting readme:readme task
[20:00:54] starting readme generator
[20:00:55] finished readme generator 50ms
ReferenceError: foo is not defined
    at eval (engine.templateSources[1]:16: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: <Generator default [string] /home/charlike/dev/__play/async-simple-iterator/verbfile.js>

The another again fails with above output. It was simply:

'use strict'

module.exports = function generator(verb) {
  verb.helper('foo', require('helper-date'))
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:38 (23 by maintainers)

github_iconTop GitHub Comments

1reaction
jonschlinkertcommented, Jun 17, 2016

lol thanks!

0reactions
tunnckoCorecommented, Jun 17, 2016
Read more comments on GitHub >

github_iconTop Results From Across the Web

verbose/verb-generate-readme - GitHub
This generator requires verb 0.9.0 and up, which is currently on the dev branch ... Each time the verb command is run, verb's...
Read more >
verb-readme-generator - npm Package Health Analysis - Snyk
This generator requires verb 0.9.0 and up, which is currently on the dev ... If you need more granularity just add a verbfile.js...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found